Skip to content
This repository was archived by the owner on May 11, 2026. It is now read-only.

Commit 998d119

Browse files
committed
fix: Handle non-dict flaws and HTTP error responses
1. Flaws can be strings or dicts - check type before .get() 2. Check response.ok for all HTTP errors, not just 402
1 parent e036637 commit 998d119

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

agents/connectors/cogdx.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,14 @@ def analyze_reasoning(self, reasoning_trace: str) -> Dict[str, Any]:
7070
"logical_validity": None
7171
}
7272

73+
# Handle other HTTP errors (500, 403, 429, etc.)
74+
if not response.ok:
75+
return {
76+
"error": f"http_{response.status_code}",
77+
"message": f"API returned status {response.status_code}",
78+
"logical_validity": None
79+
}
80+
7381
return response.json()
7482

7583
except Exception as e:
@@ -190,10 +198,18 @@ def verify_before_trade(
190198
else:
191199
recommendation = "reject"
192200

201+
# Handle flaws as either dicts or strings
202+
issues = []
203+
for f in flaws:
204+
if isinstance(f, dict):
205+
issues.append(f.get("name", str(f)))
206+
else:
207+
issues.append(str(f))
208+
193209
return {
194210
"approved": approved,
195211
"validity_score": validity,
196-
"issues": [f.get("name", str(f)) for f in flaws],
212+
"issues": issues,
197213
"recommendation": recommendation
198214
}
199215

0 commit comments

Comments
 (0)