PaddlePaddle/PaddleOCR · error · InvalidRequestError
file_url and file_path are mutually exclusive.
Error message
file_url and file_path are mutually exclusive.
What it means
Raised as InvalidRequestError by validate_input_source() when both file_url and file_path are provided. The API accepts exactly one input source per job; supplying both is ambiguous and is rejected client-side before any request is sent.
Source
Thrown at paddleocr/_api_client/_core.py:42
)
from .models import (
DocParsingOptions,
Model,
OCROptions,
PaddleOCRVLOptions,
PPStructureV3Options,
is_document_parsing_model,
is_ocr_model,
is_vl_model,
)
from .results import BatchStatus, Job, JobStatus, Progress
def validate_input_source(file_url: Optional[str], file_path: Optional[str]) -> None:
if not file_url and not file_path:
raise InvalidRequestError("Either file_url or file_path is required.")
if file_url and file_path:
raise InvalidRequestError("file_url and file_path are mutually exclusive.")
def default_payload(model: Model) -> dict:
if is_ocr_model(model):
return OCROptions().to_payload()
return resolve_document_options(model, None).to_payload()
def resolve_ocr_model(model: Union[Model, str]) -> Model:
resolved = resolve_model(model)
if not is_ocr_model(resolved):
raise InvalidRequestError(f"Unsupported OCR model: {model}")
return resolved
def resolve_document_model(model: Union[Model, str]) -> Model:
resolved = resolve_model(model)
if not is_document_parsing_model(resolved):View on GitHub (pinned to 2661c7c0ef)
Solutions
- Keep exactly one input source; delete the other argument.
- If you have both, decide which is authoritative (usually the local file) and drop the URL.
- Add a pre-call check that at most one is set when inputs come from config.
Example fix
# before job = client.create_ocr_job(file_url=url, file_path=local) # InvalidRequestError # after job = client.create_ocr_job(file_path=local)
Defensive patterns
Strategy: validation
Validate before calling
if file_url and file_path:
raise ValueError("pass only one of file_url or file_path") Prevention
- Never write fallback-style file_path=arg or default; pick one source explicitly.
- Centralize input-source selection in one helper.
When it happens
Trigger: Calling a submission method with non-None values for both file_url and file_path simultaneously.
Common situations: Copy-pasted config where a URL and a local path are both present, or fallback-style code like file_path=path or default_path that accidentally yields two truthy values.
Related errors
- Either file_url or file_path is required.
- fileUrl and filePath are mutually exclusive.
- Unsupported OCR model: {model}
- Unsupported document parsing model: {model}
- Unsupported model: {model}
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/bcd1cc8332ba4dc5.
Report an issue: GitHub.