From a5f17cea7923330184f3af011f79b3e4e4d1f10f Mon Sep 17 00:00:00 2001 From: OG T Date: Sun, 12 Apr 2026 19:49:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(notification):=20TYPE-1=20backup/info=20?= =?UTF-8?q?=E5=91=8A=E8=AD=A6=E4=B8=8D=E5=86=8D=E7=99=BC=E5=AF=A9=E6=89=B9?= =?UTF-8?q?=E5=8D=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit classify_notification() 不知道 alert_category,對 backup 告警 (confidence=0, auto_executed=False)返回 TYPE-3,覆蓋掉 classify_alert_early() 已設好的 notification_type=TYPE-1。 修法:在路由分支前,讓 incident.notification_type 明確值 (TYPE-1 / TYPE-4D / TYPE-8M)覆蓋 classify_notification()。 影響:backup/info/watchdog 告警只發 send_info_notification(), 不再噴帶按鈕的審批卡到 Telegram。 2026-04-12 ogt (ADR-075 bugfix) Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/services/decision_manager.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/apps/api/src/services/decision_manager.py b/apps/api/src/services/decision_manager.py index 319981b2..4ae43b85 100644 --- a/apps/api/src/services/decision_manager.py +++ b/apps/api/src/services/decision_manager.py @@ -232,6 +232,16 @@ async def _push_decision_to_telegram( _notification_type = getattr(incident, "notification_type", "") or (_notif_type.value if _notif_type else "") _alertname = incident.signals[0].labels.get("alertname", "MetaSystemAlert") if incident.signals else "MetaSystemAlert" + # 2026-04-12 ogt: classify_alert_early() 設的 notification_type 優先於 classify_notification() + # 場景:backup/info 告警被 classify_notification() 誤判為 TYPE-3(confidence=0, 無 auto_executed) + # 規則:incident.notification_type 明確為 TYPE-1 → 強制走 info 路徑 + if _notification_type == "TYPE-1": + _notif_type = NotificationType.TYPE_1 + elif _notification_type == "TYPE-4D": + _notif_type = NotificationType.TYPE_4_DRIFT + elif _notification_type == "TYPE-8M": + _notif_type = NotificationType.TYPE_8M + if _notif_type == NotificationType.TYPE_1: # 純資訊通知 — 無按鈕 tg_result = await gateway.send_info_notification(