fix(incidents): compute resolution correctly in metric issue detector #112623
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
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`.