From 6ee56a8fb5040be2637846a84ccac7426de22a7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Brunner?= Date: Mon, 9 May 2022 10:40:40 +0200 Subject: [PATCH] Fix None Type Traceback (most recent call last): File "/home/runner/.local/bin/c2cciutils-checks", line 8, in sys.exit(main()) File "/home/runner/.local/lib/python3.8/site-packages/c2cciutils/scripts/checks.py", line 25, in main full_config = c2cciutils.get_config(args.branch) File "/home/runner/.local/lib/python3.8/site-packages/c2cciutils/__init__.py", line 145, in get_config based_on_master = get_based_on_master(repo, branch, master_branch, config) if credentials else False File "/home/runner/.local/lib/python3.8/site-packages/c2cciutils/__init__.py", line 734, in get_based_on_master commits_json = graphql("commits.graphql", {"name": repo[1], "owner": repo[0], "branch": current_branch})[ TypeError: 'NoneType' object is not subscriptable --- c2cciutils/__init__.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/c2cciutils/__init__.py b/c2cciutils/__init__.py index 35747a9a8..99f40a404 100644 --- a/c2cciutils/__init__.py +++ b/c2cciutils/__init__.py @@ -731,9 +731,8 @@ def get_based_on_master( branches_re = compile_re(config["version"].get("branch_to_version_re", [])) if does_match(current_branch, branches_re): return False - commits_json = graphql("commits.graphql", {"name": repo[1], "owner": repo[0], "branch": current_branch})[ - "repository" - ]["ref"]["target"]["history"]["nodes"] + commits_json = graphql("commits.graphql", {"name": repo[1], "owner": repo[0], "branch": current_branch}).get( + "repository", {}).get("ref", {}).get("target", {}).get("history", {}).get("nodes", []) branches_json = [ branch for branch in (