Skip to content

fix(workflow_engine): Ignore Workflow.DoesNotExist in trigger_action task#114385

Merged
kcons merged 1 commit intomasterfrom
seer/fix/workflow-does-not-exist
Apr 29, 2026
Merged

fix(workflow_engine): Ignore Workflow.DoesNotExist in trigger_action task#114385
kcons merged 1 commit intomasterfrom
seer/fix/workflow-does-not-exist

Conversation

@sentry
Copy link
Copy Markdown
Contributor

@sentry sentry Bot commented Apr 29, 2026

This PR addresses the Workflow.DoesNotExist error occurring in the sentry.workflow_engine.tasks.trigger_action task.

Problem:
The trigger_action task, responsible for processing workflow actions, was failing with Workflow.DoesNotExist when attempting to fetch a Workflow object by its ID. This happens due to a race condition: a workflow might be soft-deleted (i.e., its status set to PENDING_DELETION or DELETION_IN_PROGRESS) between the time the trigger_action task is enqueued and when it actually executes.

The default Workflow.objects manager's get_queryset() method explicitly excludes workflows with these deletion statuses. Consequently, if a workflow is soft-deleted, Workflow.objects.get(id=workflow_id) will raise DoesNotExist.

Why it's an issue:
The trigger_action task's @retry decorator did not include Workflow.DoesNotExist in its ignore list. This meant that instead of silently discarding the task (as is done for Project.DoesNotExist in similar scenarios where the underlying resource is legitimately gone), the error was being captured by Sentry, leading to unnecessary noise and reported issues.

Fix:
Added Workflow.DoesNotExist to the ignore list within the @retry decorator for the trigger_action task in src/sentry/workflow_engine/tasks/actions.py. This ensures that if a workflow no longer exists (because it has been soft-deleted), the task will be silently discarded without generating an error, aligning with the expected behavior for transient resource unavailability or deletion.

Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated in the State of Delaware in 2015 as Functional Software, Inc. and is gonna need some rights from me in order to utilize my contributions in this here PR. So here's the deal: I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.

Fixes SENTRY-5JNC

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Apr 29, 2026
@kcons kcons marked this pull request as ready for review April 29, 2026 22:33
@kcons kcons requested a review from a team as a code owner April 29, 2026 22:33
@kcons kcons added the Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests label Apr 29, 2026
@kcons kcons self-requested a review April 29, 2026 22:35
@kcons kcons enabled auto-merge (squash) April 29, 2026 23:45
@kcons kcons merged commit 321a1e1 into master Apr 29, 2026
71 of 82 checks passed
@kcons kcons deleted the seer/fix/workflow-does-not-exist branch April 29, 2026 23:50
cleptric pushed a commit that referenced this pull request May 5, 2026
…task (#114385)

<!-- Describe your PR here. -->
This PR addresses the `Workflow.DoesNotExist` error occurring in the
`sentry.workflow_engine.tasks.trigger_action` task.

**Problem:**
The `trigger_action` task, responsible for processing workflow actions,
was failing with `Workflow.DoesNotExist` when attempting to fetch a
`Workflow` object by its ID. This happens due to a race condition: a
workflow might be soft-deleted (i.e., its status set to
`PENDING_DELETION` or `DELETION_IN_PROGRESS`) between the time the
`trigger_action` task is enqueued and when it actually executes.

The default `Workflow.objects` manager's `get_queryset()` method
explicitly excludes workflows with these deletion statuses.
Consequently, if a workflow is soft-deleted,
`Workflow.objects.get(id=workflow_id)` will raise `DoesNotExist`.

**Why it's an issue:**
The `trigger_action` task's `@retry` decorator did not include
`Workflow.DoesNotExist` in its `ignore` list. This meant that instead of
silently discarding the task (as is done for `Project.DoesNotExist` in
similar scenarios where the underlying resource is legitimately gone),
the error was being captured by Sentry, leading to unnecessary noise and
reported issues.

**Fix:**
Added `Workflow.DoesNotExist` to the `ignore` list within the `@retry`
decorator for the `trigger_action` task in
`src/sentry/workflow_engine/tasks/actions.py`. This ensures that if a
workflow no longer exists (because it has been soft-deleted), the task
will be silently discarded without generating an error, aligning with
the expected behavior for transient resource unavailability or deletion.

<!--

  Sentry employees and contractors can delete or ignore the following.

-->

### Legal Boilerplate

Look, I get it. The entity doing business as "Sentry" was incorporated
in the State of Delaware in 2015 as Functional Software, Inc. and is
gonna need some rights from me in order to utilize my contributions in
this here PR. So here's the deal: I retain all rights, title and
interest in and to my contributions, and by keeping this boilerplate
intact I confirm that Sentry can use, modify, copy, and redistribute my
contributions, under Sentry's choice of terms.

Fixes SENTRY-5JNC

Co-authored-by: sentry[bot] <39604003+sentry[bot]@users.noreply.github.com>
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 Trigger: getsentry tests Once code is reviewed: apply label to PR to trigger getsentry tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant