From ea063757ef24748edef851f17668bc71a66d2ebd Mon Sep 17 00:00:00 2001 From: Sergio Date: Fri, 27 Sep 2024 12:59:35 +0200 Subject: [PATCH 1/2] Improve logging on GitHub API errors Should make it easier to debug in the future --- alibot_helpers/github_utilities.py | 2 ++ report-pr-errors | 5 +++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/alibot_helpers/github_utilities.py b/alibot_helpers/github_utilities.py index bded9d83..6124f74e 100644 --- a/alibot_helpers/github_utilities.py +++ b/alibot_helpers/github_utilities.py @@ -251,6 +251,8 @@ def post(self, url, data, stable_api=True, **kwds): data = json.dumps(data) if type(data) == dict else data response = requests.post(url=url, data=data, headers=headers) sc = response.status_code + if sc == 422: + print(f"GitHub error: Unprocessable Entity", file=sys.stderr) return sc @trace diff --git a/report-pr-errors b/report-pr-errors index 37538105..b9810b6e 100755 --- a/report-pr-errors +++ b/report-pr-errors @@ -467,7 +467,7 @@ def get_pending_namespace(args): url="") -def handle_branch(cgh, pr, logs, args): +def handle_branch(cgh: GithubCachedClient, pr, logs, args): ns = get_pending_namespace(args) if args.pending else \ Namespace(commit=args.pr, status=args.status + "/error", @@ -477,7 +477,7 @@ def handle_branch(cgh, pr, logs, args): sys.exit(0) -def handle_pr_id(cgh, pr, logs, args): +def handle_pr_id(cgh: GithubCachedClient, pr, logs, args): commit = cgh.get("/repos/{repo_name}/commits/{ref}", repo_name=pr.repo_name, ref=pr.commit) @@ -538,6 +538,7 @@ def handle_pr_id(cgh, pr, logs, args): ) + def parse_pr(pr): repo_name, pr_id, pr_commit = parseGithubRef(pr) return Namespace(repo_name=repo_name, From 8fa2425fa4ed52e2e643491d45b381c651912ab5 Mon Sep 17 00:00:00 2001 From: Giulio Eulisse <10544+ktf@users.noreply.github.com> Date: Fri, 18 Oct 2024 14:47:14 +0200 Subject: [PATCH 2/2] Update report-pr-errors --- report-pr-errors | 1 - 1 file changed, 1 deletion(-) diff --git a/report-pr-errors b/report-pr-errors index b9810b6e..c356ffb8 100755 --- a/report-pr-errors +++ b/report-pr-errors @@ -538,7 +538,6 @@ def handle_pr_id(cgh: GithubCachedClient, pr, logs, args): ) - def parse_pr(pr): repo_name, pr_id, pr_commit = parseGithubRef(pr) return Namespace(repo_name=repo_name,