From 1a295b3575da6d055a77d9aaba9f3be63792c634 Mon Sep 17 00:00:00 2001 From: Yutaka Kondo Date: Thu, 28 Nov 2024 10:58:36 +0900 Subject: [PATCH] handle error Signed-off-by: Yutaka Kondo --- scripts/github_api.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/github_api.py b/scripts/github_api.py index 977fbd2..4dee71e 100644 --- a/scripts/github_api.py +++ b/scripts/github_api.py @@ -82,9 +82,11 @@ def get_workflow_duration_list( # By calling jobs API for each workflow run for index, run in enumerate(workflow_runs): - jobs = requests.get(run["jobs_url"], headers=self.headers).json()[ - "jobs" - ] + json_response = requests.get(run["jobs_url"], headers=self.headers).json() + if "jobs" not in json_response: + print(f"Error in fetching jobs from {run["jobs_url"]}: {json_response}") + continue + jobs = json_response["jobs"] run["jobs"] = {} run["duration"] = 0