fix(alerts): Batch NotificationMessage delete metric alert rows#115726
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 4dca709. Configure here.
| row.delete() | ||
| while True: | ||
| ids = list( | ||
| NotificationMessage.objects.filter(action__isnull=True).values_list("id", flat=True)[ |
There was a problem hiding this comment.
Filter criteria changed, may delete unintended rows
High Severity
The filter changed from incident__isnull=False, trigger_action__isnull=False (specifically metric alert rows) to action__isnull=True (any row without a workflow action). Despite the function being named delete_old_rows_metric_alerts, the new filter is strictly broader — it matches all rows lacking an action, including any orphaned rows where incident and trigger_action are also null. The PR description says this is just a batching change, but the filter criteria silently changed too, which could cause unintended data deletion.
Reviewed by Cursor Bugbot for commit 4dca709. Configure here.
Backend Test FailuresFailures on
|


Batch the deletion here because the table is so large it ran for 12 hours and timed out.