From 83ad546ffe45f46ea732f7ea3756b392c082f148 Mon Sep 17 00:00:00 2001 From: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 9 Apr 2026 05:41:16 +0000 Subject: [PATCH] fix: allow null materialization in ModelAlertDataSchema for ClickHouse 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 --- elementary/monitor/alerts/model_alert.py | 6 ++++-- elementary/monitor/fetchers/alerts/schema/alert_data.py | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/elementary/monitor/alerts/model_alert.py b/elementary/monitor/alerts/model_alert.py index a732e7726..e28514581 100644 --- a/elementary/monitor/alerts/model_alert.py +++ b/elementary/monitor/alerts/model_alert.py @@ -18,9 +18,9 @@ def __init__( alias: str, path: str, original_path: str, - materialization: str, full_refresh: bool, alert_class_id: str, + materialization: Optional[str] = None, message: Optional[str] = None, model_unique_id: Optional[str] = None, detected_at: Optional[datetime] = None, @@ -110,7 +110,9 @@ def concise_name(self) -> str: @property def summary(self) -> str: - return f'dbt failed to build {self.materialization} "{self.alias}"' + if self.materialization: + return f'dbt failed to build {self.materialization} "{self.alias}"' + return f'dbt failed to build "{self.alias}"' def get_report_link(self) -> Optional[ReportLinkData]: return get_model_runs_link(self.report_url, self.model_unique_id) diff --git a/elementary/monitor/fetchers/alerts/schema/alert_data.py b/elementary/monitor/fetchers/alerts/schema/alert_data.py index eae594e1b..5add0df8b 100644 --- a/elementary/monitor/fetchers/alerts/schema/alert_data.py +++ b/elementary/monitor/fetchers/alerts/schema/alert_data.py @@ -249,7 +249,7 @@ class ModelAlertDataSchema(BaseAlertDataSchema): alias: str path: str original_path: str - materialization: str + materialization: Optional[str] = None full_refresh: bool message: Optional[str] = None resource_type: ResourceType = Field(ResourceType.MODEL, const=True) # type: ignore # noqa