{"record":{"id":"f68b677c46ffa780","repo":"PaddlePaddle/PaddleOCR","slug":"bad-request-msg","errorCode":null,"errorMessage":"Bad request: {msg}","messagePattern":"Bad request: (.+?)","errorType":"exception","errorClass":"InvalidRequestError","httpStatus":400,"severity":"error","filePath":"paddleocr/_api_client/_core.py","lineNumber":154,"sourceCode":"            start_time=ep.get(\"startTime\"),\n            end_time=ep.get(\"endTime\"),\n        )\n    return JobStatus(\n        job_id=job_id,\n        state=state,\n        progress=progress,\n        result=data.get(\"resultUrl\"),\n        error_msg=data.get(\"errorMsg\"),\n    )\n\n\ndef raise_for_status(status_code: int, msg: str) -> None:\n    if 200 <= status_code < 300:\n        return\n    if status_code in (401, 403):\n        raise AuthError(f\"Authentication failed: {msg}\")\n    if status_code == 400:\n        raise InvalidRequestError(f\"Bad request: {msg}\")\n    if status_code == 429:\n        raise RateLimitError(f\"Rate limit exceeded: {msg}\")\n    if status_code in (503, 504):\n        raise ServiceUnavailableError(status_code, f\"Service unavailable: {msg}\")\n    raise APIError(status_code, msg)\n\n\ndef unwrap_api_response(payload: dict, status_code: int) -> dict:\n    if not isinstance(payload, dict):\n        raise ResponseFormatError(\"Response body must be a JSON object.\")\n    code = payload.get(\"code\", 0)\n    if code not in (0, None):\n        raise APIError(status_code, extract_api_message_from_payload(payload) or \"\")\n    data = payload.get(\"data\")\n    if not isinstance(data, dict):\n        raise ResponseFormatError(\"Response JSON must contain object field 'data'.\")\n    return data\n","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_core.py#L136-L172","documentation":"Raised as InvalidRequestError by raise_for_status() when the HTTP response status is 400. The message embeds the service's explanation. The request was malformed or semantically invalid per the API (bad parameters, unsupported file, invalid fields), so the same request will fail again unchanged.","triggerScenarios":"Submitting a request with invalid option values, an unsupported file type, a malformed file_url, or out-of-range parameters where the service responds 400.","commonSituations":"Sending options fields the model does not support, URLs the service cannot fetch, base64/path mixups, or parameter names from an older API version.","solutions":["Read the embedded message; it names the offending field or reason.","Correct or remove the flagged parameter/option and resend.","Validate the file locally (format, size, readability) before uploading.","Cross-check option names and allowed values against the current API docs."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"from paddleocr._api_client.errors import InvalidRequestError\ntry:\n    result = await client.ocr(file_path=p, options=opts)\nexcept InvalidRequestError as e:\n    if str(e).startswith(\"Bad request\"):\n        log.error(\"fix request params: %s\", e)  # not retryable\n        raise","preventionTips":["Validate option values and file types against current docs before sending.","Treat Bad request as permanent; correct the request instead of retrying."],"tags":["http","bad-request","validation","api"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}