Skip to content

Commit

Permalink
fix(api): previous_alert referenced before assignment (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
talboren authored Feb 12, 2024
1 parent 3641e03 commit e715035
Showing 1 changed file with 18 additions and 16 deletions.
34 changes: 18 additions & 16 deletions keep/workflowmanager/workflowmanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,24 @@ def insert_events(self, tenant_id, events: typing.List[AlertDto]):
previous_alert = get_previous_alert_by_fingerprint(
tenant_id, event.fingerprint
)
# now compare:
# (no previous alert means that the workflow should run)
if previous_alert:
for field in fields_that_needs_to_be_change:
# the field hasn't change
if getattr(event, field) == previous_alert.event.get(field):
self.logger.info(
"Skipping the workflow because the field hasn't change",
extra={
"field": field,
"event": event,
"previous_alert": previous_alert,
},
)
should_run = False
break
# now compare:
# (no previous alert means that the workflow should run)
if previous_alert:
for field in fields_that_needs_to_be_change:
# the field hasn't change
if getattr(event, field) == previous_alert.event.get(
field
):
self.logger.info(
"Skipping the workflow because the field hasn't change",
extra={
"field": field,
"event": event,
"previous_alert": previous_alert,
},
)
should_run = False
break

if not should_run:
continue
Expand Down

0 comments on commit e715035

Please sign in to comment.