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