run-llama/liteparse · error · FileNotFoundError

File not found

Error message

File not found: {file_path}

What it means

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.

Solutions

  1. Check the path exists with os.path.exists / Path.exists before calling parse
  2. Use absolute paths (str(Path(p).resolve())) so results do not depend on the current working directory
  3. If you already have the bytes, pass them directly — parse(file_data) accepts bytes and skips the filesystem check
  4. Verify container/volume mounts and working directory if the code runs in a different environment than where the file was created

Example fix

// before
result = parser.parse("downloads/report.pdf")

// after
from pathlib import Path
path = Path("downloads/report.pdf").resolve()
if not path.is_file():
    raise FileNotFoundError(f"missing input: {path}")
result = parser.parse(str(path))
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
def ensure_input(file_data) -> Union[str, bytes]:
    if isinstance(file_data, bytes):
        return file_data
    p = Path(file_data)
    if not p.is_file():
        raise FileNotFoundError(f"input missing: {p.resolve()}")
    return str(p.resolve())

Type guard

from pathlib import Path
def is_existing_path(file_data) -> bool:
    return isinstance(file_data, (str, Path)) and Path(file_data).is_file()

Try / catch

from liteparse import LiteParse
try:
    result = parser.parse(user_path)
except FileNotFoundError as e:
    log.error("input file missing: %s", e)
    raise InputValidationError(str(e)) from None

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of run-llama/liteparse@22d2dd8cd7 (2026-09-08). Data as JSON: /api/errors/bb68a223376344b1. Report an issue: GitHub.

Appendix: source

Thrown at packages/python/liteparse/parser.py:725

        Args:
            file_data: Path to the document file, or raw PDF bytes.

        Returns:
            ParseResult containing the parsed document data.

        Raises:
            ParseError: If parsing fails.
            ParseTimeoutError: In pool mode, if the parse exceeded
                ``parse_timeout`` (the worker process is killed and replaced).
            FileNotFoundError: If the file doesn't exist.
        """
        if isinstance(file_data, bytes):
            payload: Union[str, bytes] = file_data
            source = f"<{len(file_data)} bytes>"
        else:
            file_path = Path(file_data)
            if not file_path.exists():
                raise FileNotFoundError(f"File not found: {file_path}")
            payload = str(file_path.absolute())
            source = payload

        if self._pool is not None:
            return self._pool.parse(payload, source)

        try:
            if isinstance(payload, bytes):
                native_result = self._native.parse_bytes(payload)
            else:
                native_result = self._native.parse(payload)
            return _convert_native_result(native_result)
        except Exception as e:
            raise ParseError(str(e)) from e

    def parse_batches(
        self,
        file_data: Union[str, Path, bytes],

View on GitHub (pinned to 22d2dd8cd7)