fix(telegram): 修復 Incident 無 title 欄位導致所有 Telegram 推送失敗
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m3s
Some checks failed
CD Pipeline / build-and-deploy (push) Failing after 2m3s
根因: _push_decision_to_telegram() 有兩處引用 incident.title, 但 Incident model 從來沒有此欄位,導致所有告警卡片推送都 拋 AttributeError,事件在 telegram_decision_push_failed 靜默失敗。 修法: - line 188: message 改用 signal annotation summary/description/alert_name - line 249: TYPE-1 title 改用 alertname label / signal.alert_name 影響: 自從 decision_manager 加入這兩行以來,所有 Telegram 通知都沒發出 (包含 TYPE-1 資訊通知和 TYPE-3 審批卡) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -182,10 +182,16 @@ async def _push_decision_to_telegram(
|
||||
try:
|
||||
from src.services.alert_rule_engine import match_rule as _match_rule
|
||||
_labels = incident.signals[0].labels if incident.signals else {}
|
||||
# 2026-04-12 ogt: Incident 沒有 title 欄位,用 signal annotation summary
|
||||
_sig_msg = (
|
||||
incident.signals[0].annotations.get("summary", "") or
|
||||
incident.signals[0].annotations.get("description", "") or
|
||||
incident.signals[0].alert_name
|
||||
) if incident.signals else ""
|
||||
_rule_resp = _match_rule({
|
||||
"labels": _labels,
|
||||
"alert_type": _labels.get("alertname", target),
|
||||
"message": incident.title or "",
|
||||
"message": _sig_msg,
|
||||
"target_resource": target,
|
||||
"namespace": incident.signals[0].labels.get("namespace", "awoooi-prod") if incident.signals else "awoooi-prod",
|
||||
"severity": risk_level,
|
||||
@@ -244,9 +250,14 @@ async def _push_decision_to_telegram(
|
||||
|
||||
if _notif_type == NotificationType.TYPE_1:
|
||||
# 純資訊通知 — 無按鈕
|
||||
# 2026-04-12 ogt: Incident 沒有 title 欄位,用 alertname
|
||||
_info_title = (
|
||||
incident.signals[0].labels.get("alertname", "") or
|
||||
incident.signals[0].alert_name
|
||||
) if incident.signals else "告警通知"
|
||||
tg_result = await gateway.send_info_notification(
|
||||
incident_id=incident.incident_id,
|
||||
title=incident.title or "告警通知",
|
||||
title=_info_title or "告警通知",
|
||||
message=reasoning[:200] if reasoning else description[:200],
|
||||
alertname=incident.signals[0].labels.get("alertname", "") if incident.signals else "",
|
||||
severity="info",
|
||||
|
||||
Reference in New Issue
Block a user