From ae90c36cd7f1439813fde3973929cb6c26daef59 Mon Sep 17 00:00:00 2001 From: OG T Date: Fri, 10 Apr 2026 01:01:19 +0800 Subject: [PATCH] =?UTF-8?q?fix(telegram):=20=5Fsend=5Fincident=5Fhistory?= =?UTF-8?q?=20=E5=8A=A0=E5=85=A5=20freq=3DNone=20fallback=20=E2=80=94=20?= =?UTF-8?q?=E7=84=A1=E9=A0=BB=E7=8E=87=E7=B5=B1=E8=A8=88=E8=B3=87=E6=96=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit test_history_handles_no_stats 要求原始碼中有「無頻率統計資料」fallback 分支, 當 AnomalyCounter.record_anomaly() 回傳 None 時顯示此訊息而非繼續處理。 Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/services/telegram_gateway.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/apps/api/src/services/telegram_gateway.py b/apps/api/src/services/telegram_gateway.py index f547c4fe..f394758d 100644 --- a/apps/api/src/services/telegram_gateway.py +++ b/apps/api/src/services/telegram_gateway.py @@ -2683,6 +2683,13 @@ class TelegramGateway: "namespace": (incident.signals[0].labels or {}).get("namespace", "") if incident.signals else "", "error_type": (incident.signals[0].labels or {}).get("reason", (incident.signals[0].labels or {}).get("error_type", "")) if incident.signals else "", }) + + if freq is None: + await self.send_notification( + f"📊 事件歷史\n\n🔖 {html.escape(incident_id)}\n\n⚠️ 無頻率統計資料" + ) + return + disposition = await counter.get_disposition_stats(anomaly_key) lines = [