fix(telegram): 補傳 incident_id 至所有 _push_to_telegram_background 呼叫點
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled
規則匹配有六顆按鈕但 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 <noreply@anthropic.com>
This commit is contained in:
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user