2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-03-03 23:54:20 +08:00
discourse/spec/services/admin_notices
Régis Hanol ae58a5a1be
FIX: Dismissing admin notices fails with 422 when tracker has NULL target (#36878)
When dismissing an admin notice, the service would look up the
associated `ProblemCheckTracker` by identifier only. This could find a
tracker with a `NULL` target, which then fails validation on update
since target is now required (as of 8ca5fb706a).

The root issue is that `problem_check_trackers.target` was added with
`null: true` and while we later added a default value of `"__NULL__"`
and a Ruby validation, we never enforced `NOT NULL` at the database
level. This allowed records with `NULL` targets to persist or be
recreated through code paths that explicitly passed nil.

This commit:

- Updates the dismiss service to look up trackers by both identifier AND
target (extracted from the admin notice's details)
- Removes any remaining records with `NULL` targets
- Adds a `NOT NULL` constraint to prevent this from recurring

Ref - https://meta.discourse.org/t/392248
2025-12-29 16:32:12 +01:00
..
dismiss_spec.rb FIX: Dismissing admin notices fails with 422 when tracker has NULL target (#36878) 2025-12-29 16:32:12 +01:00