GitHub: handle edge cases with empty responses

This commit is contained in:
Nicolas Dandrimont 2021-02-25 21:14:45 +01:00
parent c375a61b16
commit 879170a57d

View file

@ -306,6 +306,10 @@ class GitHubLister(Lister[GitHubListerState, List[Dict[str, Any]]]):
assert self.lister_obj.id is not None
for repo in page:
if not repo:
# null repositories in listings happen sometimes...
continue
pushed_at_str = repo.get("pushed_at")
pushed_at: Optional[datetime.datetime] = None
if pushed_at_str:
@ -324,6 +328,11 @@ class GitHubLister(Lister[GitHubListerState, List[Dict[str, Any]]]):
# Don't update internal state when relisting
return
if not page:
# Sometimes, when you reach the end of the world, GitHub returns an empty
# page of repositories
return
last_id = page[-1]["id"]
if last_id > self.state.last_seen_id: