{"record":{"id":"bb68a223376344b1","repo":"run-llama/liteparse","slug":"file-not-found-file-path","errorCode":null,"errorMessage":"File not found: {file_path}","messagePattern":"File not found: (.+?)","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"packages/python/liteparse/parser.py","lineNumber":725,"sourceCode":"        Args:\n            file_data: Path to the document file, or raw PDF bytes.\n\n        Returns:\n            ParseResult containing the parsed document data.\n\n        Raises:\n            ParseError: If parsing fails.\n            ParseTimeoutError: In pool mode, if the parse exceeded\n                ``parse_timeout`` (the worker process is killed and replaced).\n            FileNotFoundError: If the file doesn't exist.\n        \"\"\"\n        if isinstance(file_data, bytes):\n            payload: Union[str, bytes] = file_data\n            source = f\"<{len(file_data)} bytes>\"\n        else:\n            file_path = Path(file_data)\n            if not file_path.exists():\n                raise FileNotFoundError(f\"File not found: {file_path}\")\n            payload = str(file_path.absolute())\n            source = payload\n\n        if self._pool is not None:\n            return self._pool.parse(payload, source)\n\n        try:\n            if isinstance(payload, bytes):\n                native_result = self._native.parse_bytes(payload)\n            else:\n                native_result = self._native.parse(payload)\n            return _convert_native_result(native_result)\n        except Exception as e:\n            raise ParseError(str(e)) from e\n\n    def parse_batches(\n        self,\n        file_data: Union[str, Path, bytes],","sourceCodeStart":707,"sourceCodeEnd":743,"githubUrl":"https://github.com/run-llama/liteparse/blob/22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8/packages/python/liteparse/parser.py#L707-L743","documentation":"Standard FileNotFoundError raised by LiteParse.parse when given a file path (not bytes) that does not exist on disk. Only non-pool path handling aside, the check happens in Python before dispatching to the native parser or worker pool, so it fails fast with the offending path in the message.","triggerScenarios":"Calling parser.parse(\"some/path.pdf\") where Path(file_data).exists() is False — wrong path, missing file, relative path resolved against an unexpected working directory, or a file deleted between listing and parsing.","commonSituations":"Typos or wrong extensions in paths; running from a different working directory so a relative path no longer resolves; passing a directory or URL instead of a file path; batch jobs where input files were cleaned up; container mounts missing the input volume.","solutions":["Check the path exists with os.path.exists / Path.exists before calling parse","Use absolute paths (str(Path(p).resolve())) so results do not depend on the current working directory","If you already have the bytes, pass them directly — parse(file_data) accepts bytes and skips the filesystem check","Verify container/volume mounts and working directory if the code runs in a different environment than where the file was created"],"exampleFix":"// before\nresult = parser.parse(\"downloads/report.pdf\")\n\n// after\nfrom pathlib import Path\npath = Path(\"downloads/report.pdf\").resolve()\nif not path.is_file():\n    raise FileNotFoundError(f\"missing input: {path}\")\nresult = parser.parse(str(path))","handlingStrategy":"validation","validationCode":"from pathlib import Path\ndef ensure_input(file_data) -> Union[str, bytes]:\n    if isinstance(file_data, bytes):\n        return file_data\n    p = Path(file_data)\n    if not p.is_file():\n        raise FileNotFoundError(f\"input missing: {p.resolve()}\")\n    return str(p.resolve())","typeGuard":"from pathlib import Path\ndef is_existing_path(file_data) -> bool:\n    return isinstance(file_data, (str, Path)) and Path(file_data).is_file()","tryCatchPattern":"from liteparse import LiteParse\ntry:\n    result = parser.parse(user_path)\nexcept FileNotFoundError as e:\n    log.error(\"input file missing: %s\", e)\n    raise InputValidationError(str(e)) from None","preventionTips":["Resolve to absolute paths before parsing so behavior is cwd-independent","Check Path(p).is_file() (not just exists()) to also reject directories","Pass raw bytes when you already hold the file content","In containers, verify volume mounts and file lifecycle before batch runs"],"tags":["filesystem","file-not-found","validation","python"],"backgroundTag":"file-not-found","analyzedSha":"22d2dd8cd7f7b9320102b57ddaf0e663ff7d15a8","analyzedAt":"2026-09-08T06:09:49.009Z","contentChangedAt":"2026-09-08T06:09:49.009Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}