{"record":{"id":"0c677f15c7bc19e3","repo":"opendatalab/MinerU","slug":"input-path-does-not-exist-path","errorCode":null,"errorMessage":"Input path does not exist: {path}","messagePattern":"Input path does not exist: (.+?)","errorType":"validation","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"demo/demo.py","lineNumber":19,"sourceCode":"# Copyright (c) Opendatalab. All rights reserved.\nimport asyncio\nimport os\nimport tempfile\nfrom pathlib import Path\n\nimport httpx\n\nfrom mineru.cli import api_client as _api_client\nfrom mineru.cli.common import image_suffixes, office_suffixes, pdf_suffixes\nfrom mineru.utils.guess_suffix_or_lang import guess_suffix_by_path\n\nSUPPORTED_INPUT_SUFFIXES = set(pdf_suffixes + image_suffixes + office_suffixes)\n\n\ndef collect_input_files(input_path: str | Path) -> list[Path]:\n    path = Path(input_path).expanduser().resolve()\n    if not path.exists():\n        raise FileNotFoundError(f\"Input path does not exist: {path}\")\n\n    if path.is_file():\n        file_suffix = guess_suffix_by_path(path)\n        if file_suffix not in SUPPORTED_INPUT_SUFFIXES:\n            raise ValueError(f\"Unsupported input file type: {path.name}\")\n        return [path]\n\n    if not path.is_dir():\n        raise ValueError(f\"Input path must be a file or directory: {path}\")\n\n    input_files = sorted(\n        (\n            candidate.resolve()\n            for candidate in path.iterdir()\n            if candidate.is_file()\n            and guess_suffix_by_path(candidate) in SUPPORTED_INPUT_SUFFIXES\n        ),\n        key=lambda item: item.name,","sourceCodeStart":1,"sourceCodeEnd":37,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/demo/demo.py#L1-L37","documentation":"Raised by collect_input_files() in demo/demo.py when the path passed as input_path does not exist on disk after expanduser().resolve(). This is a fail-fast precondition check before any file-type sniffing or parsing happens. The resolved absolute path is included in the message so the user can see exactly what MinerU looked for.","triggerScenarios":"Calling the demo entry point with input_path pointing at a missing file or directory (typo, wrong cwd, unexpanded '~' that resolves to nothing, or a path on another machine/container). Anything that makes Path(input_path).expanduser().resolve().exists() return False.","commonSituations":"Relative paths run from a different working directory; typos in CLI args; Docker containers where the file was not mounted; CI jobs where artifacts were not downloaded before invocation.","solutions":["Verify the path exists: ls -l <path> and confirm spelling.","Use an absolute path, or resolve relative to a known anchor (e.g. Path(__file__).parent / 'inputs') before passing it.","If the file is expected to be generated upstream, add a check/step that produces it before calling MinerU.","In containers, confirm the volume mount actually exposes the file."],"exampleFix":"// before\nresult = parse(\"~/data/repot.pdf\")\n\n// after\nfrom pathlib import Path\np = Path(\"~/data/report.pdf\").expanduser().resolve()\nif not p.exists():\n    raise SystemExit(f\"missing input: {p}\")\nresult = parse(str(p))","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\ndef ensure_input_exists(input_path: str) -> Path:\n    p = Path(input_path).expanduser().resolve()\n    if not p.exists():\n        raise SystemExit(f\"input not found: {p}\")\n    return p","typeGuard":"from pathlib import Path\n\ndef is_existing_path(value: str) -> bool:\n    try:\n        return Path(value).expanduser().resolve().exists()\n    except OSError:\n        return False","tryCatchPattern":"try:\n    files = collect_input_files(path)\nexcept FileNotFoundError as e:\n    log.error(\"input missing: %s\", e)\n    sys.exit(2)","preventionTips":["Always expanduser().resolve() paths at your own boundary before passing them.","In scripts, anchor relative paths to Path(__file__).parent or an explicit CLI arg.","Fail fast in CI: assert inputs exist before the parse stage."],"tags":["filesystem","input-validation","path"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}