fix(critical): approval_records.incident_id 欄位未寫入 — Telegram 卡片找不到 INC 編號
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 15m15s
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 15m15s
🚨 統帥實測發現(live-fire #2, #3 反復找不到卡片): DB 查詢證據: SELECT id, incident_id, telegram_message_id FROM approval_records → incident_id=NULL, telegram_message_id=NULL (所有新 approval) 但 incidents 表確實有對應的 INC-20260414-3318E8 / 5C90CC。 根因: approval_db.approval_request_to_record_data() dict 定義完全沒有 incident_id 欄位。ApprovalRequestCreate schema line 165 明明有 incident_id: str | None, 但轉 record 時被丟掉 → DB 永遠 NULL → Telegram 卡片顯示 INC 號空白。 影響: - 用戶 Telegram 上根本認不出是哪個 incident 的審核卡 - 人工審核閉環名存實亡(即使批准也無法連回 incident) - update_telegram_message_id 路徑也無法 fallback 補回(查 NULL 找不到) 修復 (最小侵入): 在 dict 補 "incident_id": request.incident_id 影響範圍零破壞: - 舊 approval 繼續 NULL (不動) - 新 approval 此後會正確寫入 - DB schema 本來就有此欄位 (line 280 Mapped[str|None]) Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -159,6 +159,10 @@ def approval_request_to_record_data(
|
||||
"fingerprint": fingerprint,
|
||||
"hit_count": 1,
|
||||
"last_seen_at": now,
|
||||
# 2026-04-14 Claude Sonnet 4.6: 補漏 — 原本 incident_id/telegram_message_id
|
||||
# 不在 dict 裡導致 DB 欄位永遠 NULL,Telegram 卡片顯示 INC 號是空白
|
||||
# 用戶在 Telegram 根本認不出對應的告警,審核閉環名存實亡
|
||||
"incident_id": request.incident_id,
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user