File tree 2 files changed +22
-3
lines changed
src/sentry/workflow_engine/migration_helpers
tests/sentry/workflow_engine/migration_helpers
2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -191,13 +191,18 @@ def _create_workflow_and_lookup(
191
191
192
192
# the only time the data_conditions list will be empty is if somebody only has EveryEventCondition in their conditions list.
193
193
# if it's empty and this is not the case, we should not migrate
194
- no_conditions = len (data_conditions ) == 0
194
+ no_conditions = len (conditions ) == 0
195
+ no_data_conditions = len (data_conditions ) == 0
195
196
only_has_every_event_cond = (
196
197
len (conditions ) == 1 and conditions [0 ]["id" ] == EveryEventCondition .id
197
198
)
198
199
199
- if not self .is_dry_run and no_conditions and not only_has_every_event_cond :
200
- raise Exception ("No valid conditions, skipping migration" )
200
+ if not self .is_dry_run :
201
+ if no_data_conditions and no_conditions :
202
+ # originally no conditions and we expect no data conditions
203
+ pass
204
+ elif no_data_conditions and not only_has_every_event_cond :
205
+ raise Exception ("No valid trigger conditions, skipping migration" )
201
206
202
207
enabled = True
203
208
rule_snooze = RuleSnooze .objects .filter (rule = self .rule , user_id = None ).first ()
Original file line number Diff line number Diff line change @@ -290,6 +290,20 @@ def test_run__skip_migration_if_no_valid_conditions(self):
290
290
291
291
assert Workflow .objects .all ().count () == 0
292
292
293
+ def test_run__no_triggers (self ):
294
+ self .issue_alert .data ["conditions" ] = []
295
+ self .issue_alert .save ()
296
+
297
+ IssueAlertMigrator (self .issue_alert , self .user .id , should_create_actions = False ).run ()
298
+
299
+ issue_alert_workflow = AlertRuleWorkflow .objects .get (rule = self .issue_alert )
300
+ workflow = Workflow .objects .get (id = issue_alert_workflow .workflow .id )
301
+
302
+ assert workflow .when_condition_group
303
+ assert (
304
+ DataCondition .objects .filter (condition_group = workflow .when_condition_group ).count () == 0
305
+ )
306
+
293
307
def test_run__no_double_migrate (self ):
294
308
IssueAlertMigrator (self .issue_alert , self .user .id ).run ()
295
309
You can’t perform that action at this time.
0 commit comments