DeepSeek V4.1 Flash · 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
- 5
- Comments matching a bug
- 1
- Comments not matching
- 4
- Cost of this PR
- $0.130
Published comments (5)
Migration dereferences nil PG rows for missing site settings — The migration aborts with `NoMethodError` whenever no matching row exists, which is the normal case for `embed_category` and blocks the upgrade. Guard both lookups with a `cmd_tuples` check like the block below already does.
SQL injection in embeddable_hosts migration via string interpolation — A stored host containing an apostrophe crashes the migration, and other SQL fragments are executed with migration privileges. Pass the value through `connection.quote` instead of interpolating it.
Migrated embeddable hosts keep URL scheme and never match — Values stored with `http://` bypass the model's `before_validation` normalization, so `EmbeddableHost.record_for_host` never matches the scheme-free `uri.host` and embedding silently stops working. Strip the scheme and path before inserting, or route the insert through the model.
Missing embeddable host causes NoMethodError in update and destroy — A stale or crafted id raises `NoMethodError` and returns a 500 instead of a JSON error. Raise `Discourse::NotFound` unless the `EmbeddableHost` lookup returns a record before calling `save_host` or `destroy`.
before_validation raises NoMethodError when host is nil — A request that omits `host` raises `NoMethodError` in this callback and 500s before `validates_format_of` can report the field error. Skip the `sub!` calls when `host` is blank so validation handles it.