Skip to content

Commit f5e6ec5

Browse files
authored
fix(workflows): Don't reuse existing workflow in create_priority_workflow (#113133)
Workflows are organization scoped, so there shouldn't be any need to create a new priority error workflow for every project; one should be enough. However, we're still supporting the APIs/UI for Rule, and Rules were each dual written to Workflows and will soon be represented as Workflows. We can't represent per-project Rules as a single Workflow, and in the cases where we currently do, any modification to the Rule (including delete) results in inconsistency and brokenness. So, we need to ensure that newly created "rules" aren't deduplicated for now, and in another change we'll process existing shared workflows to unshare them, at least until we're no longer offering a Rule interface. Part of ISWF-2470.
1 parent ca77ff5 commit f5e6ec5

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/sentry/workflow_engine/defaults/workflows.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ def connect_workflows_to_issue_stream(
4343

4444

4545
def create_priority_workflow(org: Organization) -> Workflow:
46-
existing = Workflow.objects.filter(organization=org, name=DEFAULT_WORKFLOW_LABEL).first()
47-
if existing:
48-
return existing
49-
5046
with transaction.atomic(router.db_for_write(Workflow)):
5147
when_condition_group = DataConditionGroup.objects.create(
5248
logic_type=DataConditionGroup.Type.ANY_SHORT_CIRCUIT,

tests/sentry/workflow_engine/defaults/test_workflows.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,19 +150,19 @@ def test_creates_action_filter_and_links(self) -> None:
150150
# Verify action filter has correct logic type
151151
assert action_filter.logic_type == DataConditionGroup.Type.ANY_SHORT_CIRCUIT
152152

153-
def test_idempotent_returns_existing_workflow(self) -> None:
153+
def test_creates_separate_workflow_per_call(self) -> None:
154+
"""Each call creates a new Workflow so that each project gets its own."""
154155
org = self.create_organization()
155156

156157
workflow1 = create_priority_workflow(org)
157158
workflow2 = create_priority_workflow(org)
158159

159-
assert workflow1.id == workflow2.id
160-
# Should only have one workflow
160+
assert workflow1.id != workflow2.id
161161
assert (
162162
Workflow.objects.filter(
163163
organization=org, name="Send a notification for high priority issues"
164164
).count()
165-
== 1
165+
== 2
166166
)
167167

168168

0 commit comments

Comments
 (0)