DeepSeek V4 Pro · 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 Opus 5.5.

Gold bugs found
3 of 10
Comments published
6
Comments matching a bug
3
Comments not matching
3
Cost of this PR
$1.611

Published comments (6)

highbugapp/assets/javascripts/admin/controllers/admin-embedding.js.es6:9-16

embedding.embeddable_hosts is a plain array, so pushObject/removeObject fail — The hydrated collection is a plain array, so mutating it with Ember methods throws a TypeError and leaves the UI broken. Wrap it with `Ember.A(...)` in `_hydrateEmbedded`, or use plain `push`/`filter` here.

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

CreateEmbeddableHosts migration crashes when embed_category is unset — When `embed_category` is unset, the inner join returns no rows and indexing nil raises, skipping the intended fallback. Check `ntuples` before indexing so unset values fall back to the uncategorized category.

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

Migrated embeddable_hosts URLs are not normalized before insertion — Raw SQL inserts bypass `before_validation`, so URL-form hosts keep schemes and paths that never match `uri.host`. Normalize each host before inserting, or insert through the model so validation runs.

mediumbugspec/models/topic_spec.rb:1403-1405

Obsolete example no longer verifies embeddable_host blank condition — The expectation now passes only because `embed_truncate` defaults to false, so it no longer tests the embeddable-host condition. Remove the example or set `SiteSetting.embed_truncate = true` and stub `has_topic_embed?` to return true.

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

EmbeddableHostsController update/destroy dereferences nil for missing id — A stale or double delete returns nil from `where(...).first`, which raises NoMethodError and a 500. Use `EmbeddableHost.find(params[:id])` to render a 404, or return early when nil.

mediumbugapp/models/embeddable_host.rb:5-8

Unconditional sub! on nil host raises NoMethodError — A nil host raises NoMethodError during `before_validation`, bypassing the intended format validation and producing a 500. Normalize `self.host` to an empty string before calling `sub!`.

Gold bugs found (3)

mediumupdate and destroy in Admin::EmbeddableHostsController fetch the host with where(id:).first and never check for nil, so an unknown id raises NoMethodError and returns a 500 instead of not-found.
highThe migration copies the legacy embeddable_hosts values into the new table without stripping scheme and path, so hosts stored as http://example.com no longer match the bare-host lookup and previously allowed embeds are rejected after upgrade.
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 (7)

highrecord_for_host compares lower(host) against the un-lowercased URI host, so mixed-case referer hosts fail to match allowed hosts and embedding is rejected.
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.
mediumEmbeddableHost has no (case-insensitive) uniqueness validation or unique index, so the same host can be saved twice with different categories and record_for_host silently picks whichever row comes first.
mediumThe embeddable-host component's delete action has no .catch(popupAjaxError) on destroyRecord(), so a failed host deletion is silently swallowed and the row stays with no feedback to the admin.
mediumThe 'raises an error with a missing host' spec sends no referer, so the request fails on the nil referer regardless of the empty embeddable_hosts table; the missing-host behaviour is not actually tested.