fix(ai): 修復 Pydantic validation error + tuple unpacking
1. kubectl_command 允許 None (LLM 可能返回 null) 2. 加入 field_validator 將 null 轉換為空字串 3. generate_incident_proposal 完整解包 6 值 (含 ai_tokens/ai_cost) 2026-03-29 ogt: Gemini API validation 修復 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -94,11 +94,18 @@ class OpenClawDecision(BaseModel):
|
||||
default="default",
|
||||
description="Kubernetes namespace",
|
||||
)
|
||||
kubectl_command: str = Field(
|
||||
# 2026-03-29 ogt: 允許 None,LLM 可能返回 null
|
||||
kubectl_command: str | None = Field(
|
||||
default="",
|
||||
description="具體的 kubectl 指令",
|
||||
)
|
||||
|
||||
@field_validator("kubectl_command", mode="before")
|
||||
@classmethod
|
||||
def normalize_kubectl_command(cls, v):
|
||||
"""將 null 轉換為空字串"""
|
||||
return v if v is not None else ""
|
||||
|
||||
# === 風險評估欄位 ===
|
||||
risk_level: AIRiskLevel = Field(
|
||||
...,
|
||||
|
||||
Reference in New Issue
Block a user