fix: skip alerts with unknown Status instead of crashing#2235
Conversation
|
👋 @Darkandz |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThis PR adds resilient status parsing for alert filtering. A new ChangesSafe alert status parsing
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary
apply_filters_schema_on_alertconstructsStatus(alert.data.status)unconditionally atelementary/monitor/api/alerts/alert_filters.py:53. When a row inget_pending_alertscarriesstatus='none'(e.g., a model that was selected but not actually executed in the dbt run), the wholeedr monitorinvocation crashes withValueError: 'none' is not a valid Status. One bad row poisons the entire alert batch — no alert is delivered.Fix
Wrap the
Status(...)call in_safe_parse_status. On unknown values it logs a warning and the alert is filtered out (returnsFalse). This matches the behavior the alert would have had anyway under the default status filter (FAIL/ERROR/RUNTIME_ERROR/WARN) had'none'been a recognized value — except now the rest of the batch is unaffected.Reproduction
A real
get_pending_alertsrow from a ClickHouse-backed warehouse withstatus='none'(andmodel_unique_id,materialization,full_refreshallnull) triggers the original stack trace atalert_filters.py:53→Status('none'). After the fix the row is dropped with a logged warning; other alerts in the same batch are sent normally.Test plan
test_filter_alerts_skips_unknown_statuscovering both the default status filter and an empty status filter.Summary by CodeRabbit
Bug Fixes
Tests