{"record":{"id":"859793e9b50d6f37","repo":"PaddlePaddle/PaddleOCR","slug":"document-parsing-result-is-required","errorCode":null,"errorMessage":"document parsing result is required.","messagePattern":"document parsing result is required\\.","errorType":"validation","errorClass":"InvalidRequestError","httpStatus":null,"severity":"warning","filePath":"paddleocr/_api_client/_resources.py","lineNumber":97,"sourceCode":"            save_resource(\n                page.ocr_image_url,\n                str(dest_dir / filename),\n                overwrite=overwrite,\n                timeout=timeout,\n            )\n        )\n    return saved_paths\n\n\ndef save_document_parsing_result_resources(\n    result: DocParsingResult,\n    destination: str,\n    *,\n    overwrite: bool = False,\n    timeout: float = 300.0,\n) -> List[str]:\n    if result is None:\n        raise InvalidRequestError(\"document parsing result is required.\")\n    dest_dir = _require_existing_directory(destination)\n    saved_paths = []\n    for page in result.pages:\n        for filename, resource_url in _iter_named_resources(page.markdown_images):\n            saved_paths.append(\n                save_resource(\n                    resource_url,\n                    str(dest_dir / filename),\n                    overwrite=overwrite,\n                    timeout=timeout,\n                )\n            )\n        for filename, resource_url in _iter_named_resources(page.output_images):\n            saved_paths.append(\n                save_resource(\n                    resource_url,\n                    str(dest_dir / filename),\n                    overwrite=overwrite,","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_api_client/_resources.py#L79-L115","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass the DocParsingResult produced by the document-parsing flow (parse_doc_parsing_result output)","Guard for None at the call site with an error message that names the upstream step that failed","Use distinct variable names for OCR vs doc-parsing results to avoid passing the wrong object"],"exampleFix":"# before\nsave_document_parsing_result_resources(result, dest)  # result is None\n\n# after\nif doc_result is None:\n    raise RuntimeError(\"document parsing produced no result\")\nsave_document_parsing_result_resources(doc_result, dest)","handlingStrategy":"validation","validationCode":"if result is None or not getattr(result, 'pages', None):\n    raise RuntimeError('no document parsing result to save')","typeGuard":"from paddleocr._api_client.results import DocParsingResult\ndef is_doc_result(o) -> bool:\n    return isinstance(o, DocParsingResult) and hasattr(o, 'pages')","tryCatchPattern":"try:\n    save_document_parsing_result_resources(result, dest_dir)\nexcept InvalidRequestError as e:\n    raise RuntimeError(f'doc-parsing pipeline produced no result: {e}') from e","preventionTips":["Use distinct variable names for OCR vs document-parsing results","Fail the whole flow when the parse step yields None instead of continuing to download"],"tags":["validation","arguments","document-parsing"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}