{"record":{"id":"930b2f12f7b548f0","repo":"PaddlePaddle/PaddleOCR","slug":"file-not-found-file-path","errorCode":null,"errorMessage":"File not found: '{file_path}'","messagePattern":"File not found: '(.+?)'","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.py","lineNumber":215,"sourceCode":"\n    def _process_file(self, file_path: str) -> tuple[str, dict[str, Any]]:\n        \"\"\"Process a single file through the SDK and return text + raw result.\"\"\"\n        with PaddleOCRClient(\n            token=self._token,\n            base_url=self._base_url,\n            client_platform=\"langchain\",\n            poll_timeout=self._timeout,\n        ) as client:\n            parse_kwargs: dict[str, Any] = {\"options\": self._options}\n            if self._model is not None:\n                parse_kwargs[\"model\"] = self._model\n            if self._is_url(file_path):\n                result = client.parse_document(file_url=file_path, **parse_kwargs)\n            else:\n                local_path = Path(file_path)\n                if not local_path.exists():\n                    msg = f\"File not found: '{file_path}'\"\n                    raise ValueError(msg)\n                result = client.parse_document(\n                    file_path=str(local_path),\n                    **parse_kwargs,\n                )\n\n        text_parts = [page.markdown_text for page in result.pages if page.markdown_text]\n        text = _PAGES_DELIMITER.join(text_parts)\n\n        raw_response = {\n            \"job_id\": result.job_id,\n            \"data_info\": result.data_info,\n            \"pages\": [\n                {\n                    \"markdown_text\": page.markdown_text,\n                    \"markdown_images\": page.markdown_images,\n                    \"output_images\": page.output_images,\n                    \"pruned_result\": page.pruned_result,\n                    \"input_image_url\": page.input_image_url,","sourceCodeStart":197,"sourceCodeEnd":233,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/langchain-paddleocr/langchain_paddleocr/document_loaders/paddleocr_vl.py#L197-L233","documentation":"ValueError from PaddleOCRVLLoader's lazy loading when a non-URL file_path does not exist on the local filesystem. The loader first checks _is_url; for local inputs it verifies Path(file_path).exists() before calling client.parse_document, raising with the exact path in the message.","triggerScenarios":"Passing a relative path resolved from a different working directory; a typo'd or moved file; a remote-looking path (e.g. s3:// or ftp://) that fails the http(s) URL check and is then treated as local.","commonSituations":"Notebooks/agents running with a different cwd than expected; file already consumed/moved by a prior step; passing cloud-storage URIs unsupported by the loader.","solutions":["Pass an absolute path: `str(Path(file_path).resolve())`.","Verify the file exists before constructing the load call (os.path.isfile).","For remote files, use an http(s) URL so _is_url routes it to parse_document(file_url=...), or download it locally first."],"exampleFix":"// before\nloader = PaddleOCRVLLoader(\"data/report.pdf\")\ndocs = loader.load()  # ValueError if cwd != project root\n\n// after\nfrom pathlib import Path\nloader = PaddleOCRVLLoader(str(Path(\"data/report.pdf\").resolve()))\ndocs = loader.load()","handlingStrategy":"validation","validationCode":"from pathlib import Path\nimport urllib.parse as _u\n\ndef is_http_url(s: str) -> bool:\n    p = _u.urlparse(s)\n    return p.scheme in (\"http\", \"https\") and bool(p.netloc)\n\ndef loader_input_ok(file_path: str) -> bool:\n    return is_http_url(file_path) or Path(file_path).is_file()","typeGuard":"def is_loadable_source(src: object) -> bool:\n    \"\"\"True for http(s) URLs or existing local files.\"\"\"\n    if not isinstance(src, str):\n        return False\n    p = urlparse(src)\n    if p.scheme in (\"http\", \"https\") and p.netloc:\n        return True\n    return Path(src).is_file()","tryCatchPattern":"try:\n    docs = PaddleOCRVLLoader(path).load()\nexcept ValueError as e:\n    if \"File not found\" in str(e):\n        path = str(Path(path).resolve())  # or download from remote storage first\n        docs = PaddleOCRVLLoader(path).load()\n    else:\n        raise","preventionTips":["Resolve paths to absolute before passing to the loader.","Use http(s) URLs for remote documents; download cloud-storage objects locally first.","In agents/notebooks, assert the file exists in the cell before the (lazy) load call."],"tags":["python","langchain","file-not-found","path","document-loader"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}