Skip to content

fix(workflows): Don't return Workflows while they're being deleted#112541

Merged
kcons merged 1 commit intomasterfrom
kcons/markit
Apr 8, 2026
Merged

fix(workflows): Don't return Workflows while they're being deleted#112541
kcons merged 1 commit intomasterfrom
kcons/markit

Conversation

@kcons
Copy link
Copy Markdown
Member

@kcons kcons commented Apr 8, 2026

Fixes ISWF-2420.

@kcons kcons requested review from a team as code owners April 8, 2026 21:43
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 8, 2026

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

@saponifi3d saponifi3d left a comment

Choose a reason for hiding this comment

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

overall lgtm!

scheduled = CellScheduledDeletion.schedule(rule, days=0, actor=request.user)
# The Rule's scheduled deletion should take care of the workflow, but
# we mark it pending immediately so we don't return it while the deletion is in progress.
for workflow in Workflow.objects.filter(alertruleworkflow__rule_id=rule.id):
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.

For another PR; thoughts on us modifying the manager to handle this for us? we are doing that pattern in Detectors here.

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.

Ah yeah, I'd actually forgotten I was going to do this to the association tables.
I still intend to do that (actually, have a PR going), but in this case, the Workflow is logically deleted, even if you're not going through the association table, so we can't rely on the association table to hide it, we need to mark it pending.

rule_id=rule_id, workflow__organization=project.organization
rule_id=rule_id,
workflow__organization=project.organization,
workflow__status=ObjectStatus.ACTIVE,
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.

any concerns around indexes / query times with filtering by status?

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.

Not in this case. we're already filtering on workflow attributes here. This does remind me that we could be selecting workflow here and saving a fetch, but that's a separate issue.

Copy link
Copy Markdown
Member

@markstory markstory left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

@kcons kcons merged commit 9c185a6 into master Apr 8, 2026
57 checks passed
@kcons kcons deleted the kcons/markit branch April 8, 2026 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants