{"record":{"id":"0b58423889825b21","repo":"PaddlePaddle/PaddleOCR","slug":"either-file-url-or-file-path-is-required","errorCode":null,"errorMessage":"Either file_url or file_path is required.","messagePattern":"Either file_url or file_path is required\\.","errorType":"validation","errorClass":"InvalidRequestError","httpStatus":null,"severity":"error","filePath":"paddleocr/_api_client/_core.py","lineNumber":40,"sourceCode":"    ResponseFormatError,\n    ServiceUnavailableError,\n)\nfrom .models import (\n    DocParsingOptions,\n    Model,\n    OCROptions,\n    PaddleOCRVLOptions,\n    PPStructureV3Options,\n    is_document_parsing_model,\n    is_ocr_model,\n    is_vl_model,\n)\nfrom .results import BatchStatus, Job, JobStatus, Progress\n\n\ndef validate_input_source(file_url: Optional[str], file_path: Optional[str]) -> None:\n    if not file_url and not file_path:\n        raise InvalidRequestError(\"Either file_url or file_path is required.\")\n    if file_url and file_path:\n        raise InvalidRequestError(\"file_url and file_path are mutually exclusive.\")\n\n\ndef default_payload(model: Model) -> dict:\n    if is_ocr_model(model):\n        return OCROptions().to_payload()\n    return resolve_document_options(model, None).to_payload()\n\n\ndef resolve_ocr_model(model: Union[Model, str]) -> Model:\n    resolved = resolve_model(model)\n    if not is_ocr_model(resolved):\n        raise InvalidRequestError(f\"Unsupported OCR model: {model}\")\n    return resolved\n\n\ndef resolve_document_model(model: Union[Model, str]) -> Model:","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_core.py#L22-L58","documentation":"Raised as InvalidRequestError by validate_input_source() in _core.py when neither file_url nor file_path is supplied. Every file-submission API requires exactly one of the two, so the call is rejected before any network request is made. This is a client-side usage error, not a service failure.","triggerScenarios":"Calling create-OCR or document-parsing methods with both file_url=None and file_path=None, e.g. passing only options/model or misspelling the keyword argument.","commonSituations":"Misspelled kwarg (file_path vs filepath), passing a Path-like variable that is None, or refactoring code that used to inline the path.","solutions":["Pass exactly one of file_url or file_path to the submission call.","Check for typos in the keyword name (it is file_url / file_path).","Assert the variable holding the path is set before calling."],"exampleFix":"# before\njob = await client.ocr(filepath=\"a.png\")  # both args None -> InvalidRequestError\n\n# after\njob = await client.ocr(file_path=\"a.png\")","handlingStrategy":"validation","validationCode":"def ensure_input(file_url=None, file_path=None):\n    if not file_url and not file_path:\n        raise ValueError(\"provide file_url or file_path\")\n    if file_url and file_path:\n        raise ValueError(\"provide only one of file_url / file_path\")\n\nensure_input(file_url, file_path)\nclient.ocr(file_url=file_url, file_path=file_path)","typeGuard":null,"tryCatchPattern":"from paddleocr._api_client.errors import InvalidRequestError\ntry:\n    job = await client.ocr(file_path=path)\nexcept InvalidRequestError as e:\n    if \"required\" in str(e):\n        # fill in the missing source argument\n        ...","preventionTips":["Use keyword arguments (file_url=/file_path=) so typos surface fast.","Assert exactly one of the two variables is set when inputs come from config."],"tags":["validation","input","client-side"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}