{"record":{"id":"aa42cfdc31c327ff","repo":"binary-husky/gpt_academic","slug":"unsupported-format-path-suffix-supported-aa42cf","errorCode":null,"errorMessage":"Unsupported format: {path.suffix}. Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}","messagePattern":"Unsupported format: (.+?)\\. Supported: (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"crazy_functions/doc_fns/read_fns/unstructured_all/unstructured_reader.py","lineNumber":130,"sourceCode":"        path = Path(file_path).resolve()\n\n        if not path.exists():\n            raise ValueError(f\"File not found: {path}\")\n\n        if not path.is_file():\n            raise ValueError(f\"Not a file: {path}\")\n\n        if not os.access(path, os.R_OK):\n            raise PermissionError(f\"No read permission: {path}\")\n\n        file_size_mb = path.stat().st_size / (1024 * 1024)\n        if file_size_mb > max_size_mb:\n            raise ValueError(\n                f\"File size ({file_size_mb:.1f}MB) exceeds limit of {max_size_mb}MB\"\n            )\n\n        if path.suffix.lower() not in self.SUPPORTED_EXTENSIONS:\n            raise ValueError(\n                f\"Unsupported format: {path.suffix}. \"\n                f\"Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}\"\n            )\n\n        return path\n\n    def _cleanup_text(self, text: str) -> str:\n        \"\"\"清理文本\n\n        Args:\n            text: 原始文本\n\n        Returns:\n            str: 清理后的文本\n        \"\"\"\n        if self.config.text_cleanup['remove_extra_spaces']:\n            text = ' '.join(text.split())\n","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/binary-husky/gpt_academic/blob/d6bde0fa54373309bd05823a49bda8da019d2c77/crazy_functions/doc_fns/read_fns/unstructured_all/unstructured_reader.py#L112-L148","documentation":"UnstructuredReader's English extension allowlist error: raised when path.suffix.lower() is not in SUPPORTED_EXTENSIONS. The message includes the sorted supported list so the caller knows exactly what is accepted.","triggerScenarios":"Feeding files with extensions outside the allowlist (.rtf, .epub, .txt where only pdf/docx/tex etc. are supported, or no extension at all); case is handled via .lower() so .PDF is fine.","commonSituations":"Folder-ingestion pipelines forwarding every file; users renaming files to fake extensions; versions of the reader with different supported sets than the caller assumes; dotfiles with no suffix yielding ''.","solutions":["Pre-filter input files by the supported set: {p for p in files if p.suffix.lower() in reader.SUPPORTED_EXTENSIONS}.","Convert unsupported formats with pandoc/libreoffice into a supported one.","Upgrade the library if newer versions support the format.","Correct misnamed extensions (file content vs suffix mismatch)."],"exampleFix":"# before\nfor f in Path(folder).rglob('*'):\n    reader.read(f)  # ValueError on .zip/.jpg sidecars\n\n# after\nok = reader.SUPPORTED_EXTENSIONS\nfor f in Path(folder).rglob('*'):\n    if f.is_file() and f.suffix.lower() in ok:\n        reader.read(f)","handlingStrategy":"type-guard","validationCode":"ok = reader.SUPPORTED_EXTENSIONS\nif Path(fp).suffix.lower() not in ok:\n    fp = convert_to(fp, target_ext='pdf')","typeGuard":"def ext_supported(path: str, reader) -> bool:\n    from pathlib import Path\n    return Path(path).suffix.lower() in reader.SUPPORTED_EXTENSIONS","tryCatchPattern":"try:\n    reader.read(fp)\nexcept ValueError as e:\n    if str(e).startswith('Unsupported format'):\n        convert_then_retry(fp)\n    raise","preventionTips":["Filter folders by the allowlist before batch reads.","Convert with pandoc/libreoffice at ingest.","Upgrade the reader when new formats are needed.","Beware dotfiles/extensionless paths yielding ''."],"tags":["file-format","validation","extension","python"],"backgroundTag":null,"analyzedSha":"d6bde0fa54373309bd05823a49bda8da019d2c77","analyzedAt":"2026-08-14T22:48:35.038Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}