Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,7 @@
class IssuePriorityDeescalatingConditionHandler(DataConditionHandler[WorkflowEventData]):
group = DataConditionHandler.Group.ACTION_FILTER
subgroup = DataConditionHandler.Subgroup.ISSUE_ATTRIBUTES
comparison_json_schema = {
"anyOf": [
{"type": "integer", "enum": [*PriorityLevel]},
# Temporary compatibility for the automation builder's broken default.
# Remove after ISWF-3453 is complete and stored comparisons are cleaned up.
{"type": "boolean", "const": True},
]
}
comparison_json_schema = {"type": "integer", "enum": [*PriorityLevel]}

@staticmethod
def evaluate_value(event_data: WorkflowEventData, comparison: Any) -> bool:
Expand All @@ -39,8 +32,8 @@ def evaluate_value(event_data: WorkflowEventData, comparison: Any) -> bool:
# use this to determine if we've breached the comparison priority before
highest_seen_priority = open_period.data.get("highest_seen_priority", current_priority)

# Preserve the current behavior for the automation builder's broken default.
# Remove this compatibility path after ISWF-3453 is complete.
# Existing rows may still contain the automation builder's previous boolean default.
# Keep evaluation compatible until those rows are migrated to a priority threshold.
if comparison is True:
return group.status == GroupStatus.RESOLVED

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def test_issue_priority_deescalating(self) -> None:
self._validator(Condition.ISSUE_PRIORITY_DEESCALATING, PriorityLevel.HIGH).is_valid()
is True
)
assert self._validator(Condition.ISSUE_PRIORITY_DEESCALATING, True).is_valid() is True
assert self._validator(Condition.ISSUE_PRIORITY_DEESCALATING, True).is_valid() is False
assert self._validator(Condition.ISSUE_PRIORITY_DEESCALATING, False).is_valid() is False
assert self._validator(Condition.ISSUE_PRIORITY_DEESCALATING, 100).is_valid() is False

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,6 @@ def setUp(self) -> None:
condition_result=True,
condition_group=dc_critical.condition_group,
)
self.deescalating_dc_boolean = self.create_data_condition(
comparison=True,
type=self.condition,
condition_result=True,
condition_group=dc_critical.condition_group,
)

def update_group_and_open_period(self, priority: PriorityLevel) -> None:
self.group.update(priority=priority)
Expand Down Expand Up @@ -107,12 +101,21 @@ def test_critical(self) -> None:
self.assert_passes(self.deescalating_dc_critical, self.event_data)

def test_boolean_comparison_preserves_existing_behavior(self) -> None:
boolean_condition = self.create_data_condition(
comparison=DetectorPriorityLevel.HIGH,
type=self.condition,
condition_result=True,
condition_group=self.deescalating_dc_critical.condition_group,
)
type(boolean_condition).objects.filter(id=boolean_condition.id).update(comparison=True)
boolean_condition.refresh_from_db()

self.update_group_and_open_period(priority=PriorityLevel.HIGH)
self.update_group_and_open_period(priority=PriorityLevel.MEDIUM)
self.assert_does_not_pass(self.deescalating_dc_boolean, self.event_data)
self.assert_does_not_pass(boolean_condition, self.event_data)

self.group.update(status=GroupStatus.RESOLVED)
self.assert_passes(self.deescalating_dc_boolean, self.event_data)
self.assert_passes(boolean_condition, self.event_data)

@override_options(
{"workflow_engine.group.type_id.open_periods_type_denylist": [DEFAULT_TYPE_ID]}
Expand Down
Loading