Skip to content

Commit c623c4e

Browse files
authored
fix(workflow_engine): Add a try / except to reduce noise in processing conditions (#91751)
## Description Reduce noise from this [issue](https://sentry.sentry.io/issues/6606822297/?project=1&query=is%3Aunresolved%20issue.priority%3A%5Bhigh%2C%20medium%5D&referrer=issue-stream&stream_index=7).
1 parent 1a3db2d commit c623c4e

File tree

2 files changed

+16
-2
lines changed

2 files changed

+16
-2
lines changed

src/sentry/workflow_engine/models/data_condition.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,20 @@ def evaluate_value(self, value: T) -> DataConditionResult:
163163
if condition_type in CONDITION_OPS:
164164
# If the condition is a base type, handle it directly
165165
op = CONDITION_OPS[Condition(self.type)]
166-
result = op(cast(Any, value), self.comparison)
166+
result = None
167+
try:
168+
result = op(cast(Any, value), self.comparison)
169+
except TypeError:
170+
logger.exception(
171+
"Invalid comparison for data condition",
172+
extra={
173+
"comparison": self.comparison,
174+
"value": value,
175+
"type": self.type,
176+
"condition_id": self.id,
177+
},
178+
)
179+
167180
return self.get_condition_result() if result else None
168181

169182
# Otherwise, we need to get the handler and evaluate the value

tests/sentry/workflow_engine/models/test_data_condition.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,9 @@ def test_bad_comparison(self):
5858
)
5959

6060
# Raises a TypeError because str vs int comparison
61-
with pytest.raises(TypeError):
61+
with mock.patch("sentry.workflow_engine.models.data_condition.logger") as mock_logger:
6262
dc.evaluate_value(2)
63+
assert mock_logger.exception.call_args[0][0] == "Invalid comparison for data condition"
6364

6465
def test_condition_result_comparison_fails(self):
6566
dc = self.create_data_condition(

0 commit comments

Comments
 (0)