fix(workflow): stop using soft-deleted workflows (EN-1225) - #188
Conversation
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.
|
Warning Review limit reached
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 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 configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
Superseded by #199, which consolidates this change with the related reliability and safety fixes on top of the current main branch. |
Problem (H5 — HIGH)
RunWorkflow(manager.go:84-91) andReadWorkflow(:140-149) selected byidonly, with nodeleted_at IS NULL. AfterDELETE /workflows/{id},POST /workflows/{id}/instancesstill launched new instances and the workflow was still readable.DeleteWorkflowhad nodeleted_atguard, so deleting twice rewrote the timestamp instead of returning not-found.listMatchingTriggers(listener) andActivities.ListTriggersfiltered onlytrigger.deleted_at, so triggers attached to a deleted workflow kept firing instances forever.Fix
RunWorkflow/ReadWorkflow: adddeleted_at IS NULL.DeleteWorkflow: adddeleted_at IS NULLguard ⇒ re-delete returnsErrWorkflowNotFound.WHERE workflow_id IN (SELECT id FROM workflows WHERE deleted_at IS NULL).Tests
TestListMatchingTriggersgains a trigger of soft-deleted workflow excluded case.TestSoftDeletedWorkflowIsNotUsablecovers read / run / re-delete.Severity: HIGH.