Claude Sonnet 5.5 · Heavy

feature-can-edit-category-host-relationships-for-embedding-discourse-cursor

Discourse · Ruby · M · 100–299 lines · 6 files

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. 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
$1.983

Published comments (5)

highbugdb/migrate/20150818190757_create_embeddable_hosts.rb:22-26

Migration inserts embeddable hosts with scheme and path, breaking host matching — Migrated hosts that keep a scheme or path, like `https://example.com/1234`, never match `URI(...).host` in `EmbeddableHost.record_for_host`, so embedding breaks after upgrade. Strip the scheme, path and whitespace from each `h` and quote the value with `ActiveRecord::Base.connection.quote`.

highbugdb/migrate/20150818190757_create_embeddable_hosts.rb:9-16

Migration crashes when embed_category or uncategorized setting has no rows — When `embed_category` is unset or names no category, the query returns no rows and indexing `[0]` raises NoMethodError, so the migration fails. Check `cmd_tuples` on the result before reading it, for both the `embed_category` and `uncategorized_category_id` lookups.

mediumbugapp/models/embeddable_host.rb:14-17

record_for_host ignores host case and port when matching stored hosts — A referer like `http://EvilTrout.com/` won't match a stored lowercase host, and a stored `host:port` entry can never match, so embedding fails for valid hosts. Downcase `uri.host` and also match `"#{uri.host}:#{uri.port}"` in `record_for_host`.

mediumbugapp/models/embeddable_host.rb:5-8

before_validation raises NoMethodError when host is nil — A missing or nil `host` makes `self.host.sub!` raise NoMethodError, so the request returns a 500 instead of a validation error. Skip the cleanup when `host` is nil, or assign `host.to_s.sub(...)` instead of mutating in place.

mediumbugapp/controllers/admin/embeddable_hosts_controller.rb:9-18

update and destroy raise NoMethodError (500) when the host id is missing — A missing or already-deleted id leaves `host` nil, so `save_host` and `host.destroy` raise NoMethodError and return a 500. Use `find_by` in `update` and `destroy`, and raise `Discourse::NotFound` when the record is nil.

Gold bugs found (1)

highThe migration reads execute(...)[0]['id'] for embed_category without checking for an empty result, so installs without that setting stored crash the migration instead of falling back to the uncategorized category.

Gold bugs missed (3)

mediumAfter saving a host, the component overwrites its category with findById(categoryId); when no category was chosen this is null even though the server saved the uncategorized category, so the row shows no category until reload.
highHosts saved with a port (allowed by the validation regex) are stored as host:port, but lookup compares only URI.host, so those configured hosts never match and embedding fails for them.
highEmbeddableHost's host format validation only accepts TLDs of 2-5 letters, so admins cannot add embeddable hosts on longer TLDs like example.technology.