fix(webhooks): 補 get_alert_operation_log_repository import 兩處
All checks were successful
CD Pipeline / build-and-deploy (push) Successful in 12m53s

alert_received_log_failed 錯誤原因:alertmanager_webhook 函數內
直接呼叫 get_alert_operation_log_repository() 但未在 local scope import,
導致 NameError 被 except 吞掉,ALERT_RECEIVED 事件無法記錄。

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
OG T
2026-04-09 12:29:48 +08:00
parent fc03eb1f4d
commit e4070b2f86

View File

@@ -1105,6 +1105,7 @@ async def alertmanager_webhook(
# Q9: auto_repair flag — Rule=false 強制 HITL不觸發自動修復背景任務
_can_auto_repair_by_rule = _alert_labels.get("auto_repair", "true").lower() == "true"
try:
from src.repositories.alert_operation_log_repository import get_alert_operation_log_repository
_op_log = get_alert_operation_log_repository()
await _op_log.append(
"ALERT_RECEIVED",
@@ -1377,6 +1378,7 @@ async def alertmanager_webhook(
)
else:
# auto_repair=false → 記錄 GUARDRAIL_BLOCKED不觸發自動修復
from src.repositories.alert_operation_log_repository import get_alert_operation_log_repository
_op_log_rule = get_alert_operation_log_repository()
background_tasks.add_task(
_op_log_rule.append,