From 2a6977343a4edd99c10e91c4ce24e589e357e0d0 Mon Sep 17 00:00:00 2001 From: OG T Date: Wed, 8 Apr 2026 22:40:22 +0800 Subject: [PATCH] =?UTF-8?q?fix(telegram):=20=E8=A3=9C=E5=82=B3=20incident?= =?UTF-8?q?=5Fid=20=E8=87=B3=E6=89=80=E6=9C=89=20=5Fpush=5Fto=5Ftelegram?= =?UTF-8?q?=5Fbackground=20=E5=91=BC=E5=8F=AB=E9=BB=9E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 規則匹配有六顆按鈕但 Ollama/OpenClaw 路徑只有三顆,根因是 alertmanager 和 fallback 路徑呼叫 _push_to_telegram_background 時 未傳 incident_id,導致詳情/重診/歷史按鈕不顯示。 - _push_to_telegram_background: 新增 incident_id 參數 - alertmanager 主路徑: 補傳 incident_id - alertmanager fallback 路徑: 存回傳值並補傳 - /alerts 路徑: 尚無 incident,明確傳空字串 Co-Authored-By: Claude Sonnet 4.6 --- apps/api/src/api/v1/webhooks.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/apps/api/src/api/v1/webhooks.py b/apps/api/src/api/v1/webhooks.py index 269536ce..ac13671d 100644 --- a/apps/api/src/api/v1/webhooks.py +++ b/apps/api/src/api/v1/webhooks.py @@ -343,6 +343,8 @@ async def _push_to_telegram_background( auto_tuning_command: str = "", # 2026-04-02 ogt: 修復 ai_provider 未傳遞 → Telegram 顯示「AI 仲裁判定」而非具體模型名稱 ai_provider: str = "", + # 2026-04-08 ogt: 補傳 incident_id 以啟用詳情/重診/歷史按鈕 + incident_id: str = "", ) -> None: """ 背景任務: 推送待簽核卡片到 Telegram (v7.0 含 SignOz 整合) @@ -392,6 +394,7 @@ async def _push_to_telegram_background( ai_tokens=ai_tokens, ai_cost=ai_cost, ai_provider=ai_provider, + incident_id=incident_id, ) logger.info( @@ -967,6 +970,8 @@ async def receive_alert( ai_tokens=ai_tokens, ai_cost=ai_cost, ai_provider=ai_provider, + # 2026-04-08 ogt: 補傳 incident_id 以啟用詳情/重診/歷史按鈕 + incident_id="", # /alerts 路徑尚無 incident,detail/reanalyze/history 按鈕不顯示 ) return AlertResponse( @@ -1407,6 +1412,8 @@ async def alertmanager_webhook( ai_tokens=ai_tokens, ai_cost=ai_cost, ai_provider=ai_provider, + # 2026-04-08 ogt: 補傳 incident_id 以啟用詳情/重診/歷史按鈕 + incident_id=incident_id, ) record_alert_chain_success("alertmanager") @@ -1445,7 +1452,7 @@ async def alertmanager_webhook( # ================================================================ # Incident-Approval 同步 (鐵律: 即使 LLM 失敗也必須創建) # ================================================================ - await create_incident_for_approval( + fallback_incident_id = await create_incident_for_approval( approval_id=str(approval.id), risk_level="medium", target_resource=target_resource, @@ -1467,6 +1474,7 @@ async def alertmanager_webhook( primary_responsibility="HUMAN", confidence=0.0, namespace=namespace, + incident_id=fallback_incident_id, ) return AlertResponse(