From a9748f409d42f1be80d66987f388b014a3034559 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9ophile=20Bastian?= Date: Wed, 6 Nov 2024 09:49:40 +0100 Subject: [PATCH] Alerts: prevent crash on unknown severity level --- matrix_alertbot/alert.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/matrix_alertbot/alert.py b/matrix_alertbot/alert.py index 6b3c1b5..dd07b44 100644 --- a/matrix_alertbot/alert.py +++ b/matrix_alertbot/alert.py @@ -37,7 +37,7 @@ class Alert: self.description = annotations["description"] if self.firing: - self.status = self.labels["severity"] + self.status = self.labels.get("severity", "unknown_alert") else: self.status = "resolved" @@ -55,11 +55,11 @@ class Alert: @property def emoji(self) -> str: - return self.EMOJIS[self.status] + return self.EMOJIS.get(self.status, "❓️") @property def color(self) -> str: - return self.COLORS[self.status] + return self.COLORS.get(self.status, "ffff0c") def match_label(self, label_name: str, pattern: re.Pattern[str]) -> bool: if label_name not in self.labels: