opendatalab/MinerU · error · ValueError

Unsupported input file type: {path.name}

Error message

Unsupported input file type: {path.name}

What it means

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.

Source

Thrown at demo/demo.py:24

import httpx

from mineru.cli import api_client as _api_client
from mineru.cli.common import image_suffixes, office_suffixes, pdf_suffixes
from mineru.utils.guess_suffix_or_lang import guess_suffix_by_path

SUPPORTED_INPUT_SUFFIXES = set(pdf_suffixes + image_suffixes + office_suffixes)


def collect_input_files(input_path: str | Path) -> list[Path]:
    path = Path(input_path).expanduser().resolve()
    if not path.exists():
        raise FileNotFoundError(f"Input path does not exist: {path}")

    if path.is_file():
        file_suffix = guess_suffix_by_path(path)
        if file_suffix not in SUPPORTED_INPUT_SUFFIXES:
            raise ValueError(f"Unsupported input file type: {path.name}")
        return [path]

    if not path.is_dir():
        raise ValueError(f"Input path must be a file or directory: {path}")

    input_files = sorted(
        (
            candidate.resolve()
            for candidate in path.iterdir()
            if candidate.is_file()
            and guess_suffix_by_path(candidate) in SUPPORTED_INPUT_SUFFIXES
        ),
        key=lambda item: item.name,
    )
    if not input_files:
        raise ValueError(f"No supported files found in directory: {path}")
    return input_files

View on GitHub (pinned to 4fe4bde114)

Solutions

  1. Convert the document to PDF (e.g. LibreOffice --headless --convert-to pdf) and pass the PDF.
  2. Check the file's real extension and rename it to a supported one if it was mangled.
  3. Inspect mineru.cli.common.{pdf_suffixes,image_suffixes,office_suffixes} to confirm the exact accepted list.

Example fix

# before
files = collect_input_files("notes.txt")

# after
from mineru.cli.common import pdf_suffixes, image_suffixes, office_suffixes
allowed = set(pdf_suffixes + image_suffixes + office_suffixes)
assert Path("notes.pdf").suffix in allowed
files = collect_input_files("notes.pdf")
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
from mineru.cli.common import pdf_suffixes, image_suffixes, office_suffixes

ALLOWED = set(pdf_suffixes + image_suffixes + office_suffixes)

def is_supported_file(p: Path) -> bool:
    return p.is_file() and p.suffix.lower() in ALLOWED

Type guard

from pathlib import Path
from mineru.cli.common import pdf_suffixes, image_suffixes, office_suffixes

def is_supported_input(value: str) -> bool:
    p = Path(value)
    return p.suffix.lower() in set(pdf_suffixes + image_suffixes + office_suffixes)

Try / catch

try:
    files = collect_input_files(path)
except ValueError as e:
    if "Unsupported input file type" in str(e):
        convert_to_pdf(path)  # then retry once with the .pdf
    else:
        raise

Prevention

When it happens

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

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

Related errors


AI-assisted analysis of opendatalab/MinerU@4fe4bde114 (2026-08-14). Data as JSON: /api/errors/2bd9d6f7afe93730. Report an issue: GitHub.