Skip to content

Commit af92629

Browse files
committed
Handle expected 204
In case of uploading the problemset we expect a HTTP204 which is not valid JSON and would throw an error by design.
1 parent b8b85af commit af92629

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

misc-tools/dj_utils.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,11 +147,12 @@ def upload_file(name: str, apifilename: str, file: str, data: dict = {}):
147147

148148
result = parse_api_response(name, response)
149149

150-
try:
151-
result = json.loads(result)
152-
except json.decoder.JSONDecodeError as e:
153-
print(result)
154-
raise RuntimeError(f'Failed to JSON decode the response for API file upload request {name}')
150+
if result is not None:
151+
try:
152+
result = json.loads(result)
153+
except json.decoder.JSONDecodeError as e:
154+
print(result)
155+
raise RuntimeError(f'Failed to JSON decode the response for API file upload request {name}')
155156

156157
return result
157158

0 commit comments

Comments
 (0)