{"record":{"id":"2bd9d6f7afe93730","repo":"opendatalab/MinerU","slug":"unsupported-input-file-type-path-name","errorCode":null,"errorMessage":"Unsupported input file type: {path.name}","messagePattern":"Unsupported input file type: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"demo/demo.py","lineNumber":24,"sourceCode":"\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,\n    )\n    if not input_files:\n        raise ValueError(f\"No supported files found in directory: {path}\")\n    return input_files\n","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/demo/demo.py#L6-L42","documentation":"Raised by collect_input_files() when a single input file's suffix (as determined by guess_suffix_by_path) is not in SUPPORTED_INPUT_SUFFIXES, the union of pdf_suffixes + image_suffixes + office_suffixes from mineru.cli.common. It rejects unsupported single-file inputs before any network or parse work.","triggerScenarios":"Passing a file input whose extension is not a supported PDF, image, or Office suffix (e.g. .txt, .html, .xml, unknown extensions), or whose extension case/format guess_suffix_by_path cannot map.","commonSituations":"Feeding Markdown/text exports instead of PDFs; renamed files with stripped or wrong extensions; assuming an obscure Office variant is supported when only the curated suffix lists are.","solutions":["Convert the document to PDF (e.g. LibreOffice --headless --convert-to pdf) and pass the PDF.","Check the file's real extension and rename it to a supported one if it was mangled.","Inspect mineru.cli.common.{pdf_suffixes,image_suffixes,office_suffixes} to confirm the exact accepted list."],"exampleFix":"# before\nfiles = collect_input_files(\"notes.txt\")\n\n# after\nfrom mineru.cli.common import pdf_suffixes, image_suffixes, office_suffixes\nallowed = set(pdf_suffixes + image_suffixes + office_suffixes)\nassert Path(\"notes.pdf\").suffix in allowed\nfiles = collect_input_files(\"notes.pdf\")","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom mineru.cli.common import pdf_suffixes, image_suffixes, office_suffixes\n\nALLOWED = set(pdf_suffixes + image_suffixes + office_suffixes)\n\ndef is_supported_file(p: Path) -> bool:\n    return p.is_file() and p.suffix.lower() in ALLOWED","typeGuard":"from pathlib import Path\nfrom mineru.cli.common import pdf_suffixes, image_suffixes, office_suffixes\n\ndef is_supported_input(value: str) -> bool:\n    p = Path(value)\n    return p.suffix.lower() in set(pdf_suffixes + image_suffixes + office_suffixes)","tryCatchPattern":"try:\n    files = collect_input_files(path)\nexcept ValueError as e:\n    if \"Unsupported input file type\" in str(e):\n        convert_to_pdf(path)  # then retry once with the .pdf\n    else:\n        raise","preventionTips":["Convert office/odd formats to PDF upstream so only .pdf flows into MinerU.","Normalize extensions to lowercase before validation.","Log the accepted suffix list at service startup so ops knows what to feed it."],"tags":["input-validation","file-type","format"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}