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)
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.
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.
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.
`_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.
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.
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.
'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.
`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.