Skip to content

Commit feeaf39

Browse files
authored
🐛 fix(aci): annotate workflow_id on the Action (#93754)
1 parent fdd78fa commit feeaf39

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/sentry/workflow_engine/processors/action.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from collections import defaultdict
33
from datetime import datetime, timedelta
44

5+
from django.db import models
56
from django.utils import timezone
67

78
from sentry import features
@@ -183,8 +184,11 @@ def filter_recently_fired_workflow_actions(
183184
)
184185
update_workflow_action_group_statuses(now, statuses_to_update, missing_statuses)
185186

186-
# TODO: somehow attach workflows so we can fire actions with the appropriate workflow env
187-
return Action.objects.filter(id__in=list(action_to_workflow_ids.keys()))
187+
return Action.objects.filter(id__in=list(action_to_workflow_ids.keys())).annotate(
188+
workflow_id=models.F(
189+
"dataconditiongroupaction__condition_group__workflowdataconditiongroup__workflow__id"
190+
)
191+
)
188192

189193

190194
def get_available_action_integrations_for_org(organization: Organization) -> list[RpcIntegration]:

tests/sentry/workflow_engine/processors/test_action.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ def test(self):
5656
set(DataConditionGroup.objects.all()), self.event_data
5757
)
5858
assert set(triggered_actions) == {self.action}
59+
assert {getattr(action, "workflow_id") for action in triggered_actions} == {
60+
self.workflow.id,
61+
}
5962

6063
for status in [status_1, status_2]:
6164
status.refresh_from_db()
@@ -103,6 +106,10 @@ def test_multiple_workflows_single_action__first_fire(self):
103106
)
104107
# dedupes action if both workflows will fire it
105108
assert set(triggered_actions) == {self.action}
109+
assert {getattr(action, "workflow_id") for action in triggered_actions} == {
110+
self.workflow.id,
111+
workflow.id,
112+
}
106113

107114
assert WorkflowActionGroupStatus.objects.filter(action=self.action).count() == 2
108115

@@ -125,6 +132,10 @@ def test_multiple_workflows_single_action__later_fire(self):
125132
)
126133
# fires one action for the workflow that can fire it
127134
assert set(triggered_actions) == {self.action}
135+
assert {getattr(action, "workflow_id") for action in triggered_actions} == {
136+
self.workflow.id,
137+
workflow.id,
138+
}
128139

129140
assert WorkflowActionGroupStatus.objects.filter(action=self.action).count() == 2
130141

0 commit comments

Comments
 (0)