Conversation
…e compatibility When ClickHouse stores NULL for the materialization column in alerts_v2, the JSON data contains "materialization": null. The Pydantic schema rejected this with 'none is not an allowed value' because materialization was typed as str (required, non-nullable). This change makes materialization Optional[str] in both the schema and the alert model, and handles None gracefully in string formatting. Co-Authored-By: Yosef Arbiv <yosef.arbiv@gmail.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
👋 @devin-ai-integration[bot] |
📝 WalkthroughWalkthroughTwo files updated to make the Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🟡 concise_name not updated to handle None materialization, unlike summary
The summary property was updated (lines 113-115) to gracefully handle materialization=None, but the concise_name property (lines 104-109) was not. When materialization is None, concise_name falls through to the else branch and returns "dbt model alert - {alias}", which may be incorrect (e.g., if the resource is a snapshot whose materialization data is missing). The same pattern also exists at elementary/monitor/alerts/alert_messages/builder.py:195 (asset_type = "snapshot" if alert.materialization == "snapshot" else "model"), which was also not updated.
(Refers to lines 104-109)
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
This is intentional behavior. When materialization is None, falling through to the else branch and defaulting to "model" is the correct safe fallback. The same pattern at builder.py:195 also defaults to "model" for the same reason.
A snapshot whose materialization metadata is missing would be an unusual edge case — in practice, if a snapshot is correctly configured in dbt, its materialization field would be populated as "snapshot". The scenario triggering this bug is model alerts in ClickHouse where the materialization column is NULL due to missing metadata, and defaulting those to "model" is the appropriate behavior.
The summary property was updated differently because it interpolates materialization directly into the string (which would produce "dbt failed to build None "alias""), while concise_name only checks equality against "snapshot" and never renders the raw value.
Summary
Fixes a
ValidationError(none is not an allowed value) when runningedr monitoragainst ClickHouse, where thematerializationcolumn inalerts_v2can beNULL.ModelAlertDataSchema.materializationwas typed asstr(required, non-nullable). When ClickHouse returnsnullfor this field, Pydantic v1 rejects it duringPendingAlertSchemaconstruction. This changes it toOptional[str] = Nonein both the Pydantic schema and the downstreamModelAlertModel, and handlesNonein thesummaryproperty string formatting.Downstream code (
slack.py,builder.py,base_integration.py) already guards against falsymaterializationwith truthiness checks or== "snapshot"comparisons, so no additional changes were needed there.Review & Testing Checklist for Human
ModelAlertModel.__init__:materializationwas moved afteralert_class_idto satisfy Python's rule that default-valued params follow non-default ones. Verify no callers passmaterializationpositionally (grep forModelAlertModel(— existing callers informat_alertand test utilities use keyword args, but confirm nothing was missed).concise_namewith null materialization: WhenmaterializationisNone,concise_namewill default to"model"(sinceNone == "snapshot"isFalse). Confirm this is the desired fallback behavior rather than e.g."unknown".NULLmaterialization row inalerts_v2and confirmedr monitorno longer crashes.Notes
NULLfor thematerializationcolumn when a model's materialization metadata is unavailable. Other warehouses may populate this field more reliably, which is why this hasn't surfaced outside ClickHouse.Link to Devin session: https://app.devin.ai/sessions/362d19b8c47b47dd9b895f512ffdd30f
Requested by: @arbiv
Summary by CodeRabbit