From bf3f7f4162dfa4d7dae9a1fb9550da4bea6e10d8 Mon Sep 17 00:00:00 2001 From: Adrian Date: Wed, 6 Mar 2024 18:01:12 -0800 Subject: [PATCH] add case when owner doesn't exist --- shared/torngit/github.py | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/shared/torngit/github.py b/shared/torngit/github.py index 8f4ae9444..bf0d645cc 100644 --- a/shared/torngit/github.py +++ b/shared/torngit/github.py @@ -1669,19 +1669,25 @@ async def get_languages_graphql( body=query, token=token, ) - repositories = res["data"]["repositoryOwner"]["repositories"] - hasNextPage = repositories["pageInfo"]["hasNextPage"] - endCursor = repositories["pageInfo"]["endCursor"] - - for repo in repositories["nodes"]: - languages = repo["languages"]["edges"] - res_languages = [] - for language in languages: - res_languages.append(language["node"]["name"]) - - all_repositories.append( - RepoWithLanguages(name=repo["name"], languages=res_languages) - ) + repoOwner = res["data"]["repositoryOwner"] + if not repoOwner: + hasNextPage = False + else: + repositories = repoOwner["repositories"] + hasNextPage = repositories["pageInfo"]["hasNextPage"] + endCursor = repositories["pageInfo"]["endCursor"] + + for repo in repositories["nodes"]: + languages = repo["languages"]["edges"] + res_languages = [] + for language in languages: + res_languages.append(language["node"]["name"]) + + all_repositories.append( + RepoWithLanguages( + name=repo["name"], languages=res_languages + ) + ) return all_repositories