Skip to content

Commit 0b3bff4

Browse files
authored
Guard against invalid JSON responses (#97)
1 parent cf2d5e3 commit 0b3bff4

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

devstats/query.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ def send_query(query, query_type, headers, cursor=None):
101101
time.sleep(1 * 60)
102102
retries -= 1
103103
else:
104-
data = json.loads(response.content)
104+
try:
105+
data = json.loads(response.content)
106+
except json.decoder.JSONDecodeError as e:
107+
print(f"Invalid JSON received: {e}; retrying")
108+
print("Raw content:", response.content)
109+
retries -= 1
105110
if "exceeded a secondary rate limit" in data.get("message", ""):
106111
print("GitHub secondary rate limit exceeded; retrying after 2mins")
107112
time.sleep(2 * 60)

0 commit comments

Comments
 (0)