From 9ddcb3a1fd12a805fd27b317912416dc96a81233 Mon Sep 17 00:00:00 2001 From: Pablo Seibelt Date: Tue, 18 Apr 2023 17:06:05 -0300 Subject: [PATCH] fix: Handle empty stargazers (#192) * Fix stargazers empty * Have to convert to list first --- tap_github/repository_streams.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tap_github/repository_streams.py b/tap_github/repository_streams.py index d8505284..cb5520a9 100644 --- a/tap_github/repository_streams.py +++ b/tap_github/repository_streams.py @@ -1603,8 +1603,11 @@ def get_next_page_token( # If since parameter is present, try to exit early by looking at the last "starred_at". # Noting that we are traversing in DESCENDING order by STARRED_AT. if since: - results = extract_jsonpath(self.query_jsonpath, input=response.json()) - *_, last = results + results = list(extract_jsonpath(self.query_jsonpath, input=response.json())) + # If no results, return None to exit early. + if len(results) == 0: + return None + last = results[-1] if parse(last["starred_at"]) < parse(since): return None return super().get_next_page_token(response, previous_token)