MiniMax M3 · Balanced
feature-can-edit-category-host-relationships-for-embedding-discourse-cursor
Discourse · Ruby · M · 100–299 lines · 6 files
The normal review, with one generalist agent. Judge: Claude Haiku 5.5.
- Gold bugs found
- 1 of 4
- Comments published
- 4
- Comments matching a bug
- 1
- Comments not matching
- 3
- Cost of this PR
- $0.118
Published comments (4)
SQL injection via unsanitized embeddable_hosts interpolation — The `execute` call interpolates `embeddable_hosts` setting values into raw SQL, so any host containing a quote, backslash, or `'),'` either crashes the migration or injects unintended statements. Switch to `sanitize_sql_array` with placeholders so values are bound, not concatenated.
Migration crashes when embed_category site_setting is missing — The first `execute("... WHERE s.name = 'embed_category'")[0]['id'].to_i` dereferences `[0]` with no guard, so a missing `embed_category` site_setting raises NoMethodError before the `uncategorized_category_id` fallback runs. Stash the row in a local, check `cmd_tuples > 0`, and default to 0 when absent.
before_validation crashes when host is nil — `before_validation` chains two `self.host.sub!` calls, so a nil `host` raises NoMethodError before `validates_format_of` ever runs. Guard with `return unless host.is_a?(String)` so the callback is a safe no-op when the attribute hasn't been assigned.
Admin::EmbeddingController#update does no persistence, just re-renders — `Admin::EmbeddingController#update` re-renders the `OpenStruct` without persisting, so any PUT to `/admin/customize/embedding` returns 200 while changing nothing. Drop the route and the action, or make it perform the work the API expects.