Skip to content

Conversation

@mifu67
Copy link
Contributor

@mifu67 mifu67 commented Jan 6, 2026

Since we know before data condition evaluation that this is the case, skip processing and return early.

@mifu67 mifu67 requested review from a team and ceorourke January 6, 2026 00:23
@mifu67 mifu67 requested a review from a team as a code owner January 6, 2026 00:23
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jan 6, 2026

@patch("sentry.incidents.subscription_processor.metrics")
def test_invalid_aggregation_value(self, mock_metrics: MagicMock) -> None:
self.send_update("nan")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you might want the value to be float("nan") to actually make it a nan rather than a string

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

strings are by default not numbers so I think any string is okay (if we do the math.isnan check)

aggregation_value = self.get_aggregation_value(subscription_update, comparison_delta)

if aggregation_value is None:
if aggregation_value is None or math.isnan(aggregation_value):

This comment was marked as outdated.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

aggregation_value = self.get_aggregation_value(subscription_update, comparison_delta)

if aggregation_value is None:
if aggregation_value is None or math.isnan(aggregation_value):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

math.isnan() crashes on non-numeric aggregation values

High Severity

The math.isnan() function requires a numeric argument and raises TypeError for non-numeric types. When aggregation_value is a non-numeric, non-None value (like a string), the condition aggregation_value is None is False, causing math.isnan(aggregation_value) to be evaluated and crash. The test sends "not a number" string which would trigger this TypeError. A type check is needed before calling math.isnan(), or use a pattern like isinstance(aggregation_value, (int, float)) and math.isnan(aggregation_value).

Additional Locations (1)

Fix in Cursor Fix in Web

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's ever possible to not send a numeric value; fixed the test

@mifu67 mifu67 merged commit d6959a8 into master Jan 8, 2026
66 checks passed
@mifu67 mifu67 deleted the mifu67/aci/fix-nan branch January 8, 2026 19:02
@github-actions github-actions bot locked and limited conversation to collaborators Jan 24, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants