From ed73cea771800fef8d495b3005d66e7f20470dce Mon Sep 17 00:00:00 2001 From: "Antoine R. Dumont (@ardumont)" Date: Mon, 20 Jan 2020 10:06:34 +0100 Subject: [PATCH] github.lister: Filter out partial repositories which break listing This commit fixes the repository mapping to model. It broke when the listed repository was either None or missing the id field [1] [1] https://sentry.softwareheritage.org/share/issue/532d682182fc43d6a7a99400e3928811/ --- swh/lister/github/lister.py | 3 ++- .../tests/data/https_api.github.com/repositories,since=0 | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/swh/lister/github/lister.py b/swh/lister/github/lister.py index 40eb4e2..8916b39 100644 --- a/swh/lister/github/lister.py +++ b/swh/lister/github/lister.py @@ -49,7 +49,8 @@ class GitHubLister(IndexingHttpLister): def transport_response_simplified(self, response): repos = response.json() - return [self.get_model_from_repo(repo) for repo in repos] + return [self.get_model_from_repo(repo) + for repo in repos if repo and 'id' in repo] def request_headers(self): """(Override) Set requests headers to send when querying the GitHub API diff --git a/swh/lister/github/tests/data/https_api.github.com/repositories,since=0 b/swh/lister/github/tests/data/https_api.github.com/repositories,since=0 index 8c36346..e70aec6 100644 --- a/swh/lister/github/tests/data/https_api.github.com/repositories,since=0 +++ b/swh/lister/github/tests/data/https_api.github.com/repositories,since=0 @@ -66,6 +66,10 @@ "releases_url": "https://api.github.com/repos/mojombo/grit/releases{/id}", "deployments_url": "https://api.github.com/repos/mojombo/grit/deployments" }, + { + "description": "Azure Qu..." + }, + {}, { "id": 26, "node_id": "MDEwOlJlcG9zaXRvcnkyNg==",