Skip to content

Commit 8fbdacf

Browse files
authored
Merge pull request #76 from Open-Athena/codex/github-api-error-status
Include HTTP status in GitHub API errors
2 parents b0f96b3 + 3c5fb21 commit 8fbdacf

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

src/gha_runner/gh.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@ def _do_request(self, func, endpoint, **kwargs):
9292
resp: requests.Response = func(endpoint_url, headers=headers, **kwargs)
9393
if not resp.ok:
9494
raise RuntimeError(
95-
f"Error in API call for {endpoint_url}: " f"{resp.content}"
95+
f"Error in API call for {endpoint_url}: "
96+
f"{resp.status_code} {resp.reason}: {resp.content}"
9697
)
9798
else:
9899
try:

tests/test_gh.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,16 @@ def test_get_runners_error(github_instance):
129129
responses.add(
130130
responses.GET,
131131
"https://api.github.com/repos/test/test/actions/runners",
132+
body="server unavailable",
132133
status=500,
133134
)
134-
with pytest.raises(RunnerListError, match="Error getting runners: *"):
135+
with pytest.raises(
136+
RunnerListError,
137+
match=(
138+
"Error getting runners: Error in API call for .*: "
139+
"500 Internal Server Error: b'server unavailable'"
140+
),
141+
):
135142
github_instance.get_runners()
136143

137144

0 commit comments

Comments
 (0)