{"record":{"id":"7ce74b3c18cdb56a","repo":"PaddlePaddle/PaddleOCR","slug":"response-body-is-not-valid-json-e-7ce74b","errorCode":null,"errorMessage":"Response body is not valid JSON: {e}","messagePattern":"Response body is not valid JSON: (.+?)","errorType":"exception","errorClass":"ResponseFormatError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_http.py","lineNumber":60,"sourceCode":"\n\ndef _extract_api_message(response: requests.Response) -> str:\n    try:\n        payload = response.json()\n    except ValueError:\n        return response.text\n    if isinstance(payload, dict):\n        msg = extract_api_message_from_payload(payload)\n        if msg:\n            return msg\n    return response.text\n\n\ndef _response_json(response: requests.Response) -> Dict[str, Any]:\n    try:\n        payload = response.json()\n    except ValueError as e:\n        raise ResponseFormatError(f\"Response body is not valid JSON: {e}\") from e\n    if not isinstance(payload, dict):\n        raise ResponseFormatError(\"Response body must be a JSON object.\")\n    return payload\n\n\ndef _response_data(response: requests.Response) -> Dict[str, Any]:\n    payload = _response_json(response)\n    return unwrap_api_response(payload, response.status_code)\n\n\ndef _job_id_from_response(response: requests.Response) -> str:\n    return extract_job_id(_response_data(response))\n\n\nclass HTTPClient:\n    def __init__(\n        self,\n        token: str,","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_http.py#L42-L78","documentation":"Error \"Response body is not valid JSON: {e}\" thrown in PaddlePaddle/PaddleOCR.","triggerScenarios":"Raised by _response_json() when requests.Response.json() fails because the body is not valid JSON.","commonSituations":"The HTTP response body could not be parsed as JSON. Occurs with proxy errors, HTML error pages, or truncated responses. Check network intermediaries and the endpoint URL.","solutions":["Confirm the server actually returned JSON; check the HTTP status code and Content-Type header of the response.","If a proxy or gateway returned an HTML error page, fix the proxy, credentials, or base URL.","Retry the request; transient server errors can produce non-JSON bodies."],"exampleFix":"resp = session.post(url, json=body, timeout=timeout)\nprint(resp.status_code, resp.headers.get(\"Content-Type\"))\nprint(resp.text[:500])  # inspect the non-JSON body","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}