From de5796522f62aad9b4c986935a8879885a00e37d Mon Sep 17 00:00:00 2001 From: OG T Date: Mon, 23 Mar 2026 01:40:00 +0800 Subject: [PATCH] fix(api): fix optimization_suggestions dict access in proposal generation The optimization_suggestions field is list[dict], not list[object]. Use .get() to access dict keys instead of attribute access. Co-Authored-By: Claude Opus 4.5 --- apps/api/src/services/openclaw.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/apps/api/src/services/openclaw.py b/apps/api/src/services/openclaw.py index 96687ece8..25eaa72a3 100644 --- a/apps/api/src/services/openclaw.py +++ b/apps/api/src/services/openclaw.py @@ -1155,7 +1155,7 @@ Focus on: from_cache=from_cache, ) - # 轉換為 proposal dict + # 轉換為 proposal dict (optimization_suggestions 是 list[dict]) proposal_dict = { "action": result.action_title, "description": result.description, @@ -1168,9 +1168,9 @@ Focus on: "primary_responsibility": result.primary_responsibility, "optimization_suggestions": [ { - "type": s.type, - "description": s.description, - "kubectl_or_config": s.kubectl_or_config, + "type": s.get("type", "UNKNOWN"), + "description": s.get("description", ""), + "kubectl_or_config": s.get("kubectl_or_config", ""), } for s in result.optimization_suggestions ],