Skip to content

Commit f709ff4

Browse files
authored
fix: don't parse error 500 (#857)
The error may not be a json message or the json message may not contains message/errors attributes. This change make the logging more generic and just print the HTTP response.
1 parent 9907b68 commit f709ff4

File tree

1 file changed

+7
-17
lines changed

1 file changed

+7
-17
lines changed

mergify_cli/utils.py

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import json
2222
import os
2323
import pathlib
24-
import sys
2524
import typing
2625
from urllib import parse
2726

@@ -53,22 +52,13 @@ async def check_for_status(response: httpx.Response) -> None:
5352
if response.status_code < 400:
5453
return
5554

56-
if response.status_code < 500:
57-
await response.aread()
58-
data = response.json()
59-
console.print(f"url: {response.request.url}", style="red")
60-
console.print(f"data: {response.request.content.decode()}", style="red")
61-
console.print(
62-
f"HTTPError {response.status_code}: {data['message']}",
63-
style="red",
64-
)
65-
if "errors" in data:
66-
console.print(
67-
"\n".join(f"* {e.get('message') or e}" for e in data["errors"]),
68-
style="red",
69-
)
70-
sys.exit(1)
71-
55+
await response.aread()
56+
console.print(f"url: {response.request.url}", style="red")
57+
console.print(f"data: {response.request.content.decode()}", style="red")
58+
console.print(
59+
f"HTTPError {response.status_code}: {response.text}",
60+
style="red",
61+
)
7262
response.raise_for_status()
7363

7464

0 commit comments

Comments
 (0)