diff --git a/apps/api/src/api/v1/webhooks.py b/apps/api/src/api/v1/webhooks.py index 3c76e501..fad40c41 100644 --- a/apps/api/src/api/v1/webhooks.py +++ b/apps/api/src/api/v1/webhooks.py @@ -1350,6 +1350,14 @@ async def alertmanager_webhook( notification_type="TYPE-1", alert_category=alert_category, ) + # 2026-04-15 ogt: TYPE-1 純資訊告警建立後立即關閉 + # 設計原則: backup/heartbeat/info 告警無需追蹤狀態,通知即完成 + # 防止 incidents 表無限累積 INVESTIGATING 記錄(ADR-073 漏洞修補) + background_tasks.add_task( + get_incident_service().resolve_incident, + _info_incident_id, + "info_notification", + ) background_tasks.add_task( get_telegram_gateway().send_info_notification, incident_id=_info_incident_id, diff --git a/apps/api/src/repositories/incident_repository.py b/apps/api/src/repositories/incident_repository.py index 3e3558cd..f84d4748 100644 --- a/apps/api/src/repositories/incident_repository.py +++ b/apps/api/src/repositories/incident_repository.py @@ -79,7 +79,14 @@ def _incident_to_record_data(incident: Incident) -> dict[str, Any]: "resolved_at": incident.resolved_at, "closed_at": incident.closed_at, "frequency_snapshot": frequency_snapshot, - "alertname": incident.signals[0].alert_name if incident.signals else None, # ADR-073 Phase 2-1 + # ADR-073 Phase 2-1: alertname 欄位 — 優先從 signals[0].alert_name, + # fallback 到 signals[0].labels["alertname"](防止 signal 建立時 alert_name 為空) + # 2026-04-15 ogt: 補 labels fallback(4 筆歷史 NULL 根因修復) + "alertname": ( + (incident.signals[0].alert_name or + (incident.signals[0].labels or {}).get("alertname")) + if incident.signals else None + ), "notification_type": incident.notification_type, # ADR-073 Phase 2-2 "alert_category": incident.alert_category, # ADR-073 Phase 2-2 }