Claude Opus 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
8
Comments matching a bug
1
Comments not matching
7
Cost of this PR
$3.344

Published comments (8)

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

Migrated embeddable hosts keep scheme/path and never match lookups — `EmbeddableHost.record_for_host` compares `lower(host)` to a bare `uri.host`, so copied values like `http://eviltrout.com` never match and previously allowed sites get rejected. Strip scheme, path and whitespace and lowercase each line before the INSERT, as the model's `before_validation` does.

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

Migration crashes when `embed_category` site setting is unset — `embed_category` is unset by default, so the JOIN returns no rows and `[0]['id']` raises, aborting the migration on most installs. Check `cmd_tuples > 0` before indexing, like the `embeddable_hosts` query below.

highsecurityapp/models/embeddable_host.rb:14-17

Host lookup fails for referer URLs with uppercase domain letters — Ruby's URI keeps the hostname's case, so a referer like `http://EvilTrout.com/x` never matches `lower(host)` and gets rejected, losing its topic category. Compare against `host.downcase` instead.

highbugapp/assets/javascripts/discourse/models/store.js.es6:196-201

`_ids` hydration drops unresolved ids and throws on null values — Existing `_ids` fields without a sideloaded collection become arrays of `undefined`, and a null value makes `obj[k].map` throw. Hydrate only when `Array.isArray(obj[k])` and every lookup succeeds, otherwise keep the original key like the singular branch.

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

Missing EmbeddableHost in update/destroy raises NoMethodError (500) — `EmbeddableHost.where(id: params[:id]).first` returns nil for a missing or deleted id, so `host.host=` in `save_host` or `host.destroy` raises `NoMethodError`. Use `find` so a missing record returns a not-found response instead of a 500.

mediumbugspec/models/topic_spec.rb:1403-1405

Embeddable-host test passes vacuously and doesn't test host gating — It passes only because `embed_truncate` defaults to false and `has_topic_embed?` is unstubbed, while `expandable_first_post?` no longer checks hosts. Set `embed_truncate = true` and stub `has_topic_embed?` to true, or delete the test since that behavior is gone.

mediumbugtest/javascripts/models/store-test.js.es6:111-117

'find embedded' test fetches fruit 2 but asserts fruit 1's colors — Fruit 2 has `color_ids: [3]`, so the test passes only because the `/fruits/:id` pretender always returns `fruits[0]`. Use `store.find('fruit', 1)` so the expected colors match the requested record.

mediumbugapp/models/embeddable_host.rb:5-8

`before_validation` raises NoMethodError when `host` is nil — When `params[:embeddable_host][:host]` is missing, `self.host.sub!` raises `NoMethodError` and the request returns a 500 instead of a validation error. Skip the cleanup when `host` is blank.

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.