Skip to content

feat(ACI): Dual delete Workflow/Rule if flag enabled#110003

Merged
ceorourke merged 3 commits intomasterfrom
ceorourke/ISWF-2185
Mar 9, 2026
Merged

feat(ACI): Dual delete Workflow/Rule if flag enabled#110003
ceorourke merged 3 commits intomasterfrom
ceorourke/ISWF-2185

Conversation

@ceorourke
Copy link
Copy Markdown
Member

@ceorourke ceorourke commented Mar 5, 2026

Try to look up the related Rule object and delete that as well if we are passed a workflow to the issue alert rule delete method. In #109752 I assumed we'd always be getting a single written workflow but that may not always be the case.

@ceorourke ceorourke requested a review from a team as a code owner March 5, 2026 22:56
@linear-code
Copy link
Copy Markdown

linear-code bot commented Mar 5, 2026

@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Mar 5, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

data=rule.get_audit_log_data(),
transaction_id=scheduled.id,
)
except (AlertRuleWorkflow.DoesNotExist, Rule.DoesNotExist):
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unhandled MultipleObjectsReturned in AlertRuleWorkflow lookup

Medium Severity

AlertRuleWorkflow.objects.get(workflow_id=rule.id) can raise MultipleObjectsReturned, which isn't caught by the except clause on line 452. The AlertRuleWorkflow model's unique_together constraints are on (workflow, rule_id) and (workflow, alert_rule_id) pairs, not on workflow alone, so a single workflow_id can have multiple rows (one linking a rule_id, another linking an alert_rule_id). This would cause a 500 error after the Workflow has already been successfully marked for deletion. Filtering with rule_id__isnull=False or using filter().first() would be safer.

Fix in Cursor Fix in Web

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure we don't have anything in the db like that

@ceorourke ceorourke merged commit 550c778 into master Mar 9, 2026
56 checks passed
@ceorourke ceorourke deleted the ceorourke/ISWF-2185 branch March 9, 2026 16:32
@github-actions github-actions bot locked and limited conversation to collaborators Mar 25, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants