{"record":{"id":"179f211aee0a79a4","repo":"PaddlePaddle/PaddleOCR","slug":"response-body-must-be-a-json-object-179f21","errorCode":null,"errorMessage":"Response body must be a JSON object.","messagePattern":"Response body must be a JSON object\\.","errorType":"exception","errorClass":"ResponseFormatError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_http.py","lineNumber":62,"sourceCode":"def _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,\n        base_url: str,\n        timeout: float,","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_http.py#L44-L80","documentation":"Error \"Response body must be a JSON object.\" thrown in PaddlePaddle/PaddleOCR.","triggerScenarios":"Raised by _response_json() when the response is valid JSON but the top-level value is not an object (dict).","commonSituations":"The parsed JSON body was not an object (e.g., an array or scalar). Indicates an unexpected endpoint or API change. Verify the request URL and API version.","solutions":["Ensure the API endpoint returns a JSON object at the top level, not a list or scalar.","Check the base URL and API path; a wrong endpoint may return a JSON array or plain value.","Inspect the parsed payload to see what the server returned instead of an object."],"exampleFix":"payload = response.json()\nif not isinstance(payload, dict):\n    print(payload)  # inspect unexpected JSON shape","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"}