fix(telegram): 首席架構師 R1 修正 — I-1/I-2/M-1/M-2
Some checks failed
CD Pipeline / build-and-deploy (push) Has been cancelled

I-1: webhooks/sentry_webhook/signoz_webhook 三個呼叫者補 TODO 說明
     無 incident_id 是已知限制(Approval 路徑未建 Incident 關聯)
I-2: TestPushRequest 新增 incident_id 欄位,使 QA 可驗證按鈕渲染
M-1: 移除 _build_inline_keyboard 呼叫中多餘的 `or message.incident_id`
M-2: 補充 900/1000 截斷長度差異說明

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-05 13:07:42 +08:00
parent aa9e2c9dd3
commit 665f93e83f
5 changed files with 9 additions and 2 deletions

View File

@@ -443,6 +443,7 @@ async def send_sentry_telegram_alert(
level = error_context.get("level", "error")
# 發送 Sentry 告警卡片 (含 Y/n 按鈕)
# TODO(2026-04-05): Sentry 路徑無 incident_id待 Sentry→Incident 關聯後補傳
await telegram.send_approval_card(
approval_id=approval_id,
risk_level="high" if level in ["fatal", "error"] else "medium",

View File

@@ -369,6 +369,7 @@ async def send_signoz_telegram(
summary = annotations.get("summary", f"SignOz Alert: {alert_name}")
description = annotations.get("description", "")
# TODO(2026-04-05): SignOz 路徑無 incident_id待 SignOz→Incident 關聯後補傳
await telegram.send_approval_card(
approval_id=approval_id,
risk_level=analysis_result.risk_level if analysis_result else (

View File

@@ -60,6 +60,8 @@ class TestPushRequest(BaseModel):
root_cause: str = "Test alert for development"
suggested_action: str = "DELETE_POD"
estimated_downtime: str = "~30s"
# 2026-04-05 Claude Code: 支援 incident_id 以測試第二排按鈕渲染
incident_id: str = ""
# =============================================================================
@@ -234,6 +236,7 @@ async def test_push(
root_cause=request.root_cause,
suggested_action=request.suggested_action,
estimated_downtime=request.estimated_downtime,
incident_id=request.incident_id,
)
return {

View File

@@ -198,6 +198,8 @@ async def _push_to_telegram_background(
if hit_count > 1:
root_cause_with_count = f"[x{hit_count}] {root_cause}"
# TODO(2026-04-05): Alertmanager 路徑透過 Approval 建立,尚無 incident_id
# 待 Approval→Incident 關聯建立後,補傳 incident_id 以啟用 detail/reanalyze/history 按鈕
await gateway.send_approval_card(
approval_id=approval_id,
risk_level=risk_level,

View File

@@ -293,7 +293,7 @@ class TelegramMessage:
f"🔍 <a href='{signoz_url}'>SignOz Trace</a>"
)
return message[:900]
return message[:900] # 900 字元上限 (nemotron 版用 1000因有額外 tool 區塊)
def format_with_nemotron(self) -> str:
"""
@@ -1364,7 +1364,7 @@ class TelegramGateway:
approval_id=approval_id,
include_auto_tuning=bool(auto_tuning_command),
auto_tuning_command=auto_tuning_command,
incident_id=incident_id or message.incident_id,
incident_id=incident_id,
)
# 發送訊息