GPT-6.1 Sol · 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
2 of 4
Comments published
4
Comments matching a bug
2
Comments not matching
2
Cost of this PR
$0.721

Published comments (4)

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

Empty embed category lookup aborts migration before fallback — Installations with an empty `embed_category` setting abort the migration because `execute(...)[0]['id']` accesses a missing result. Check for an empty result before reading `['id']` so the uncategorized fallback can run.

highbugdb/migrate/20150818190757_create_embeddable_hosts.rb:24-25

Migrated hosts retain schemes and paths that prevent host matching — Previously allowed hosts stop working after upgrade because `EmbeddableHost.record_for_host` compares hostnames against migrated `h` values that may retain schemes or paths. Strip schemes and paths from `h` before inserting, matching the normalization in `app/models/embeddable_host.rb`.

highbugapp/models/embeddable_host.rb:2

Host validation rejects valid top-level domains longer than five letters — Valid hosts such as `example.technology` can no longer be added or edited because `validates_format_of :host` caps top-level domains at five letters. Remove the upper length limit.

highbugapp/models/embeddable_host.rb:17

Uppercase URL hostnames fail to match allowed embedding hosts — URLs with uppercase hostnames are denied during embedding authorization and topic retrieval because `where` lowercases only the stored value. Lowercase `host` before binding it to the query.

Gold bugs found (2)

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.
highEmbeddableHost's host format validation only accepts TLDs of 2-5 letters, so admins cannot add embeddable hosts on longer TLDs like example.technology.

Gold bugs missed (2)

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.