From 443bd7202a38fc97a7b639119cd78dc5fc1ef6d6 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Mon, 8 Sep 2025 21:26:01 -0700 Subject: [PATCH] Guard against invalid JSON responses --- devstats/query.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/devstats/query.py b/devstats/query.py index d4f4226..720313b 100644 --- a/devstats/query.py +++ b/devstats/query.py @@ -101,7 +101,12 @@ def send_query(query, query_type, headers, cursor=None): time.sleep(1 * 60) retries -= 1 else: - data = json.loads(response.content) + try: + data = json.loads(response.content) + except json.decoder.JSONDecodeError as e: + print(f"Invalid JSON received: {e}; retrying") + print("Raw content:", response.content) + retries -= 1 if "exceeded a secondary rate limit" in data.get("message", ""): print("GitHub secondary rate limit exceeded; retrying after 2mins") time.sleep(2 * 60)