Summary
All generated _parse_response functions in open_api_client/api/**/ call response.json() unconditionally for every error HTTP status code (400, 401, 403, 404, 409, 413, 415, 500, 503). When Polarion returns an HTML error page or an empty body instead of JSON (e.g. on a 400 or 401), this raises a raw json.decoder.JSONDecodeError before the library can raise a proper PolarionApiException.
Steps to reproduce
- Send any PATCH/POST/GET request against a Polarion endpoint that returns a non-JSON error body (e.g. an Apache 401 HTML page).
- The client raises
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0) instead of PolarionApiUnexpectedException.
Traceback from real pipeline run
File "polarion_rest_api_client/open_api_client/api/work_items/patch_work_item.py", line 59, in _parse_response
response_400 = Errors.from_dict(response.json())
^^^^^^^^^^^^^^^
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
Expected behaviour
A PolarionApiUnexpectedException (or PolarionApiException with the status code) should be raised instead, allowing callers to handle the error correctly and the retry mechanism to work.
Fix
Wrap every response.json() call in the generated _parse_response functions in a try/except json.JSONDecodeError and return None on failure so _raise_on_error emits PolarionApiUnexpectedException.
Summary
All generated
_parse_responsefunctions inopen_api_client/api/**/callresponse.json()unconditionally for every error HTTP status code (400, 401, 403, 404, 409, 413, 415, 500, 503). When Polarion returns an HTML error page or an empty body instead of JSON (e.g. on a 400 or 401), this raises a rawjson.decoder.JSONDecodeErrorbefore the library can raise a properPolarionApiException.Steps to reproduce
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)instead ofPolarionApiUnexpectedException.Traceback from real pipeline run
Expected behaviour
A
PolarionApiUnexpectedException(orPolarionApiExceptionwith the status code) should be raised instead, allowing callers to handle the error correctly and the retry mechanism to work.Fix
Wrap every
response.json()call in the generated_parse_responsefunctions in atry/except json.JSONDecodeErrorand returnNoneon failure so_raise_on_erroremitsPolarionApiUnexpectedException.