fix(bird_x): normalize list responses from Bird search to dict format

When Bird's JSON response is a raw array instead of an object,
json.loads returns a list. All callers use .get('items') which raises
AttributeError on lists. Wrap list responses in {"items": parsed} so
callers always receive a dict.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Trevin Chow
2026-04-09 01:26:14 -07:00
parent dedf615114
commit 65399eb4eb
+4 -1
View File
@@ -213,7 +213,10 @@ def _run_bird_search(query: str, count: int, timeout: int) -> Dict[str, Any]:
if not output: if not output:
return {"items": []} return {"items": []}
return json.loads(output) parsed = json.loads(output)
if isinstance(parsed, list):
return {"items": parsed}
return parsed
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
return {"error": f"Invalid JSON response: {e}", "items": []} return {"error": f"Invalid JSON response: {e}", "items": []}