DeepSeek V4 Pro · 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 Opus 5.5.
- Gold bugs found
- 3 of 10
- Comments published
- 5
- Comments matching a bug
- 3
- Comments not matching
- 2
- Cost of this PR
- $0.641
Published comments (5)
Embeddable hosts migration crashes on empty embed_category lookup — The lookup returns an empty result when `embed_category` is unset or matches no category name, so `[0]['id']` raises and the migration aborts before migrating any hosts. Check for an empty result before dereferencing, for example with `.first` or an explicit branch.
Embeddable host migration stores scheme/path, breaking record_for_host matching — Legacy values like `http://eviltrout.com` or `https://example.com/1234` keep their scheme and path, while `EmbeddableHost.record_for_host` compares only `uri.host`, so those hosts never match after upgrade. Normalize each `h` by stripping scheme and path before inserting, mirroring the model's `before_validation`.
before_validation host normalization raises NoMethodError on nil host — A missing `host` parameter reaches `self.host.sub!` as nil and raises NoMethodError, turning a validation problem into a 500. Guard with `host.blank?` or return early before the substitutions.
Nil host raises NoMethodError in update and destroy — A non-existent id makes `EmbeddableHost.where(id: params[:id]).first` nil, and both `update` and `destroy` dereference it, producing NoMethodError instead of a client-visible error. Guard for a missing record and render a 404 or error response.
Imported topic loses category when embed host is not allowlisted — When `record_for_host(url)` returns nil, `eh.try(:category_id)` is nil and `PostCreator` falls back to the uncategorized category. Feed-polled topics pass URLs with no host allowlist check, so use `SiteSetting.embed_category` as the fallback to preserve the intended category.