Skip to content

typing fix

518a1a6
Select commit
Loading
Failed to load commit list.
Merged

fix(incidents): compute resolution correctly in metric issue detector #112623

typing fix
518a1a6
Select commit
Loading
Failed to load commit list.
@sentry/warden / warden: sentry-backend-bugs completed Apr 10, 2026 in 4m 1s

1 issue

sentry-backend-bugs: Found 1 issue (1 high)

High

detection_type comparison will never match AlertRuleDetectionType.DYNAMIC - `src/sentry/incidents/metric_issue_detector.py:264`

The parameter detection_type is typed as str | None and receives string values like "dynamic" from config.get("detection_type"). The comparison at line 264 compares this string against AlertRuleDetectionType.DYNAMIC, which is a TextChoices enum, not a string. This comparison will always be False because "dynamic" == AlertRuleDetectionType.DYNAMIC evaluates to False. As a result, dynamic detection type alerts will get the wrong resolution calculation (the else branch instead of the if branch). The correct pattern is shown at line 479: AlertRuleDetectionType.DYNAMIC.value.


Duration: 3m 59s · Tokens: 2.3M in / 21.9k out · Cost: $2.78 (+extraction: $0.00, +fix_gate: $0.00)

Annotations

Check failure on line 264 in src/sentry/incidents/metric_issue_detector.py

See this annotation in the file changed.

@sentry-warden sentry-warden / warden: sentry-backend-bugs

detection_type comparison will never match AlertRuleDetectionType.DYNAMIC

The parameter `detection_type` is typed as `str | None` and receives string values like `"dynamic"` from `config.get("detection_type")`. The comparison at line 264 compares this string against `AlertRuleDetectionType.DYNAMIC`, which is a TextChoices enum, not a string. This comparison will always be False because `"dynamic" == AlertRuleDetectionType.DYNAMIC` evaluates to False. As a result, dynamic detection type alerts will get the wrong resolution calculation (the `else` branch instead of the `if` branch). The correct pattern is shown at line 479: `AlertRuleDetectionType.DYNAMIC.value`.