{"record":{"id":"2c24a9a3eb0704b5","repo":"opendatalab/MinerU","slug":"unknown-file-suffix-file-suffix","errorCode":null,"errorMessage":"Unknown file suffix: {file_suffix}","messagePattern":"Unknown file suffix: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"mineru/cli/common.py","lineNumber":183,"sourceCode":"        if effective_stem != stem:\n            renamed.append((stem, effective_stem))\n\n    return unique_stems, renamed\n\n\ndef read_fn(path, file_suffix: str | None = None):\n    if not isinstance(path, Path):\n        path = Path(path)\n    with open(str(path), \"rb\") as input_file:\n        file_bytes = input_file.read()\n        if file_suffix is None:\n            file_suffix = guess_suffix_by_bytes(file_bytes, path)\n        if file_suffix in image_suffixes:\n            return images_bytes_to_pdf_bytes(file_bytes)\n        elif file_suffix in pdf_suffixes + office_suffixes:\n            return file_bytes\n        else:\n            raise Exception(f\"Unknown file suffix: {file_suffix}\")\n\n\ndef prepare_env(output_dir, pdf_file_name, parse_method):\n    local_md_dir = str(os.path.join(output_dir, pdf_file_name, parse_method))\n    local_image_dir = os.path.join(str(local_md_dir), \"images\")\n    os.makedirs(local_image_dir, exist_ok=True)\n    os.makedirs(local_md_dir, exist_ok=True)\n    return local_image_dir, local_md_dir\n\n\ndef convert_pdf_bytes_to_bytes(pdf_bytes, start_page_id=0, end_page_id=None):\n    try:\n        rebuilt_pdf_bytes = rewrite_pdf_bytes_with_pdfium(\n            pdf_bytes,\n            start_page_id=start_page_id,\n            end_page_id=end_page_id,\n        )\n        if rebuilt_pdf_bytes:","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/opendatalab/MinerU/blob/4fe4bde114a23ee5dd637eae99b767f4669bf58c/mineru/cli/common.py#L165-L201","documentation":"Generic Exception from read_fn(): after reading the file bytes, the suffix (provided explicitly or guessed from magic bytes via guess_suffix_by_bytes) matched neither image_suffixes nor pdf_suffixes+office_suffixes, so mineru cannot convert the input to a PDF parse stream.","triggerScenarios":"Feeding files whose true type is not PDF/image/office — e.g. .txt, .html, .csv, .epub, or a mislabeled file where content sniffing fails; passing an explicit file_suffix kwarg with an unsupported value like 'xyz' or '.tiff' when tiff is not in image_suffixes.","commonSituations":"Directory sweeps that pick up stray non-document files; users renaming files to .pdf hoping conversion happens; unusual image formats (e.g. TIFF/BMP) not in the supported suffix list; empty or truncated downloads whose magic bytes are gone.","solutions":["Convert the input to a supported format first (PDF, common image formats, DOCX/PPTX/XLSX)","Pass the correct file_suffix explicitly if guessing fails and the format is supported","Filter inputs before batch runs: only accept files with supported suffixes/magic bytes","For TIFF/BMP, convert to PNG/JPEG or wrap into a PDF before parsing"],"exampleFix":"# before\nread_fn(Path('notes.txt'))\n\n# after\n# convert to PDF first, e.g. with libreoffice or img2pdf, then:\nread_fn(Path('notes.pdf'))","handlingStrategy":"validation","validationCode":"from pathlib import Path\n\nSUPPORTED_SUFFIXES = {\".pdf\", \".png\", \".jpg\", \".jpeg\", \".bmp\", \".docx\", \".pptx\", \".xlsx\"}  # align with your mineru version\n\ndef acceptable(p: Path) -> bool:\n    return p.suffix.lower() in SUPPORTED_SUFFIXES\n\nfiles = [p for p in Path(src).iterdir() if acceptable(p)]","typeGuard":"def is_supported_document(path: str) -> bool:\n    from pathlib import Path\n    return Path(path).suffix.lower() in {\".pdf\", \".png\", \".jpg\", \".jpeg\", \".docx\", \".pptx\", \".xlsx\"}","tryCatchPattern":"try:\n    pdf_bytes = read_fn(path)\nexcept Exception as e:\n    if \"Unknown file suffix\" in str(e):\n        path = convert_to_pdf(path)  # e.g. img2pdf / libreoffice, then retry\n        pdf_bytes = read_fn(path)\n    else:\n        raise","preventionTips":["Filter batch inputs by suffix (and optionally magic bytes) before calling mineru","Convert exotic formats (TIFF/BMP/TXT/HTML) to PDF or PNG up front","Pass file_suffix explicitly when the extension is trustworthy but content sniffing is not"],"tags":["file-format","input-validation","parsing","unsupported-type"],"backgroundTag":null,"analyzedSha":"4fe4bde114a23ee5dd637eae99b767f4669bf58c","analyzedAt":"2026-08-14T21:29:18.456Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}