Skip to content

controller: clean up open alerts when a spec is deleted#2847

Open
jshearer wants to merge 1 commit intomasterfrom
jshearer/clean_up_deleted_task_notifications
Open

controller: clean up open alerts when a spec is deleted#2847
jshearer wants to merge 1 commit intomasterfrom
jshearer/clean_up_deleted_task_notifications

Conversation

@jshearer
Copy link
Copy Markdown
Contributor

When a task with active alerts is deleted, the alert resolution actions were never applied, leaving orphaned rows in alert_history with resolved_at = NULL. The alertHistory query then returned these phantom alerts for tasks that no longer exist.

  • Add cleanup_open_alerts() that sets resolved_at and deletes the associated notification tasks without sending resolution emails
  • Call it in Outcome::apply before the hard delete when live_spec_deleted is true
  • Add a one-time migration to resolve existing orphaned alerts and their notification tasks

Fixes #2846

@jshearer jshearer requested a review from travjenkins April 10, 2026 19:37
@jshearer jshearer force-pushed the jshearer/clean_up_deleted_task_notifications branch 2 times, most recently from e0949cb to b9aaffd Compare April 10, 2026 19:59
When a task with active alerts is deleted, the alert resolution actions were never applied, leaving orphaned rows in `alert_history` with `resolved_at = NULL`. The `alertHistory` query then returned these phantom alerts for tasks that no longer exist.

* Add `cleanup_open_alerts()` that sets `resolved_at` and deletes the associated notification tasks without sending resolution emails
* Call it in `Outcome::apply` before the hard delete when `live_spec_deleted` is true
* Add a one-time migration to resolve existing orphaned alerts and their notification tasks

Fixes #2846
@jshearer jshearer force-pushed the jshearer/clean_up_deleted_task_notifications branch from b9aaffd to 62096c4 Compare April 10, 2026 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

The active alerts GQL query returns deleted tasks

1 participant