PaddlePaddle/PaddleOCR · warning · InvalidRequestError

document parsing result is required.

Error message

document parsing result is required.

What it means

InvalidRequestError raised by save_document_parsing_result_resources when its result argument is None. Client-side guard run before the destination directory check; nothing else has executed when it fires.

Source

Thrown at paddleocr/_api_client/_resources.py:97

            save_resource(
                page.ocr_image_url,
                str(dest_dir / filename),
                overwrite=overwrite,
                timeout=timeout,
            )
        )
    return saved_paths


def save_document_parsing_result_resources(
    result: DocParsingResult,
    destination: str,
    *,
    overwrite: bool = False,
    timeout: float = 300.0,
) -> List[str]:
    if result is None:
        raise InvalidRequestError("document parsing result is required.")
    dest_dir = _require_existing_directory(destination)
    saved_paths = []
    for page in result.pages:
        for filename, resource_url in _iter_named_resources(page.markdown_images):
            saved_paths.append(
                save_resource(
                    resource_url,
                    str(dest_dir / filename),
                    overwrite=overwrite,
                    timeout=timeout,
                )
            )
        for filename, resource_url in _iter_named_resources(page.output_images):
            saved_paths.append(
                save_resource(
                    resource_url,
                    str(dest_dir / filename),
                    overwrite=overwrite,

View on GitHub (pinned to 2661c7c0ef)

Solutions

  1. Pass the DocParsingResult produced by the document-parsing flow (parse_doc_parsing_result output)
  2. Guard for None at the call site with an error message that names the upstream step that failed
  3. Use distinct variable names for OCR vs doc-parsing results to avoid passing the wrong object

Example fix

# before
save_document_parsing_result_resources(result, dest)  # result is None

# after
if doc_result is None:
    raise RuntimeError("document parsing produced no result")
save_document_parsing_result_resources(doc_result, dest)
Defensive patterns

Strategy: validation

Validate before calling

if result is None or not getattr(result, 'pages', None):
    raise RuntimeError('no document parsing result to save')

Type guard

from paddleocr._api_client.results import DocParsingResult
def is_doc_result(o) -> bool:
    return isinstance(o, DocParsingResult) and hasattr(o, 'pages')

Try / catch

try:
    save_document_parsing_result_resources(result, dest_dir)
except InvalidRequestError as e:
    raise RuntimeError(f'doc-parsing pipeline produced no result: {e}') from e

Prevention

When it happens

Trigger: Calling save_document_parsing_result_resources(None, dest); the DocParsingResult variable was never assigned because the document-parsing job failed earlier, or the wrong variable (e.g. the OCR result) was passed and later found None.

Common situations: Error paths that skip result assignment; mixed OCR/doc-parsing flows where the wrong result variable is reused; helper functions returning None on upstream failure.

Related errors


AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14). Data as JSON: /api/errors/859793e9b50d6f37. Report an issue: GitHub.