diff --git a/sources/main.py b/sources/main.py index d8d7955d..951988f5 100644 --- a/sources/main.py +++ b/sources/main.py @@ -125,18 +125,21 @@ async def collect_user_repositories() -> Dict: """ Collects information about all the user repositories available. + Side note: "cn" stands for contributed nodes but is shortened to conform to the code style + :returns: Complete list of user repositories. """ DBM.i("Getting user repositories list...") repositories = await DM.get_remote_graphql("user_repository_list", username=GHM.USER.login, id=GHM.USER.node_id) + repositories["data"]["user"]["repositories"]["nodes"] = [repo for repo in repositories["data"]["user"]["repositories"]["nodes"] if repo is not None] repo_names = [repo["name"] for repo in repositories["data"]["user"]["repositories"]["nodes"]] DBM.g("\tUser repository list collected!") contributed = await DM.get_remote_graphql("repos_contributed_to", username=GHM.USER.login) - contributed_nodes = [r for r in contributed["data"]["user"]["repositoriesContributedTo"]["nodes"] if r["name"] not in repo_names and not r["isFork"]] + cn = [r for r in contributed["data"]["user"]["repositoriesContributedTo"]["nodes"] if r is not None and r["name"] not in repo_names and not r["isFork"]] DBM.g("\tUser contributed to repository list collected!") - repositories["data"]["user"]["repositories"]["nodes"] += contributed_nodes + repositories["data"]["user"]["repositories"]["nodes"] += cn return repositories diff --git a/sources/manager_download.py b/sources/manager_download.py index a90bf397..96352c61 100644 --- a/sources/manager_download.py +++ b/sources/manager_download.py @@ -224,6 +224,10 @@ async def _fetch_graphql_query(query: str, retries_count: int = 10, **kwargs) -> "https://api.github.com/graphql", json={"query": Template(GITHUB_API_QUERIES[query]).substitute(kwargs)}, headers=headers ) if res.status_code == 200: + response_data = res.json() + if "errors" in response_data: + for error in response_data["errors"]: + DBM.w(f"GraphQL request returned an error: {error['message']}!") return res.json() elif res.status_code == 502 and retries_count > 0: return await DownloadManager._fetch_graphql_query(query, retries_count - 1, **kwargs)