From 65399eb4eb76f8f094914f207e3043ef00b08366 Mon Sep 17 00:00:00 2001 From: Trevin Chow Date: Thu, 9 Apr 2026 01:26:14 -0700 Subject: [PATCH] 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) --- scripts/lib/bird_x.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/lib/bird_x.py b/scripts/lib/bird_x.py index 63a6c44..66f3101 100644 --- a/scripts/lib/bird_x.py +++ b/scripts/lib/bird_x.py @@ -213,7 +213,10 @@ def _run_bird_search(query: str, count: int, timeout: int) -> Dict[str, Any]: if not output: return {"items": []} - return json.loads(output) + parsed = json.loads(output) + if isinstance(parsed, list): + return {"items": parsed} + return parsed except json.JSONDecodeError as e: return {"error": f"Invalid JSON response: {e}", "items": []}