Skip to content

fix(workflow): stop using soft-deleted workflows (EN-1225) - #188

Closed
flemzord wants to merge 1 commit into
mainfrom
fix/soft-deleted-workflows
Closed

fix(workflow): stop using soft-deleted workflows (EN-1225)#188
flemzord wants to merge 1 commit into
mainfrom
fix/soft-deleted-workflows

Conversation

@flemzord

Copy link
Copy Markdown
Member

Problem (H5 — HIGH)

  • RunWorkflow (manager.go:84-91) and ReadWorkflow (:140-149) selected by id only, with no deleted_at IS NULL. After DELETE /workflows/{id}, POST /workflows/{id}/instances still launched new instances and the workflow was still readable.
  • DeleteWorkflow had no deleted_at guard, so deleting twice rewrote the timestamp instead of returning not-found.
  • listMatchingTriggers (listener) and Activities.ListTriggers filtered only trigger.deleted_at, so triggers attached to a deleted workflow kept firing instances forever.

Fix

  • RunWorkflow / ReadWorkflow: add deleted_at IS NULL.
  • DeleteWorkflow: add deleted_at IS NULL guard ⇒ re-delete returns ErrWorkflowNotFound.
  • Both trigger-matching queries: WHERE workflow_id IN (SELECT id FROM workflows WHERE deleted_at IS NULL).

Tests

  • TestListMatchingTriggers gains a trigger of soft-deleted workflow excluded case.
  • TestSoftDeletedWorkflowIsNotUsable covers read / run / re-delete.

Severity: HIGH.

Note: touches internal/triggers/listener.go and internal/workflow/manager.go, which other PRs in this series also edit (different regions/functions); independent, may need trivial merges.

RunWorkflow and ReadWorkflow selected by id only, so a soft-deleted
workflow could still be executed (POST /workflows/{id}/instances) and
read. DeleteWorkflow had no deleted_at guard, so re-deleting rewrote the
timestamp instead of returning not-found. And the trigger-matching
queries filtered only trigger.deleted_at, so triggers attached to a
deleted workflow kept firing instances forever.

- RunWorkflow / ReadWorkflow: add deleted_at IS NULL.
- DeleteWorkflow: add deleted_at IS NULL guard (re-delete -> ErrWorkflowNotFound).
- listMatchingTriggers / Activities.ListTriggers: exclude triggers whose
  workflow is soft-deleted.

Tests: TestListMatchingTriggers gains a soft-deleted-workflow case, and
TestSoftDeletedWorkflowIsNotUsable covers read/run/re-delete.
@coderabbitai

coderabbitai Bot commented Jun 11, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@flemzord, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 11 minutes and 30 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 7083f5ba-cc8f-4a40-9e4f-8f7202432b25

📥 Commits

Reviewing files that changed from the base of the PR and between 271bf8d and ba63264.

📒 Files selected for processing (5)
  • internal/triggers/activities.go
  • internal/triggers/listener.go
  • internal/triggers/listener_test.go
  • internal/workflow/manager.go
  • internal/workflow/manager_test.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/soft-deleted-workflows

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@flemzord

flemzord commented Jun 11, 2026

Copy link
Copy Markdown
Member Author

Tracked in Jira: EN-1225 (Epic EN-1217).

@flemzord flemzord changed the title fix(workflow): stop using soft-deleted workflows fix(workflow): stop using soft-deleted workflows (EN-1225) Jun 11, 2026
@flemzord

flemzord commented Aug 5, 2026

Copy link
Copy Markdown
Member Author

Superseded by #199, which consolidates this change with the related reliability and safety fixes on top of the current main branch.

@flemzord flemzord closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant