From af2c19c5ea01a7dc3fcb1f7d77d4ebeb6fb2ed12 Mon Sep 17 00:00:00 2001 From: Jacob Strieb Date: Mon, 5 Oct 2020 13:23:40 -0400 Subject: [PATCH] Fix malformed API response Attempt to handle issue #3, but we'll see... --- github_stats.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/github_stats.py b/github_stats.py index d20e0bbb0fd..4e29832ab1e 100644 --- a/github_stats.py +++ b/github_stats.py @@ -439,6 +439,10 @@ async def lines_changed(self) -> Tuple[int, int]: for repo in await self.repos: r = await self.queries.query_rest(f"/repos/{repo}/stats/contributors") for author_obj in r: + # Handle malformed response from the API by skipping this repo + if (not isinstance(author_obj, dict) + or not isinstance(author_obj.get("author", {}), dict)): + continue author = author_obj.get("author", {}).get("login", "") if author != self.username: continue