binary-husky/gpt_academic · error · ValueError
Unsupported format: {path.suffix}. Supported: {', '.join(sor
Error message
Unsupported format: {path.suffix}. Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))} What it means
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.
Source
Thrown at crazy_functions/doc_fns/read_fns/unstructured_all/unstructured_reader.py:130
path = Path(file_path).resolve()
if not path.exists():
raise ValueError(f"File not found: {path}")
if not path.is_file():
raise ValueError(f"Not a file: {path}")
if not os.access(path, os.R_OK):
raise PermissionError(f"No read permission: {path}")
file_size_mb = path.stat().st_size / (1024 * 1024)
if file_size_mb > max_size_mb:
raise ValueError(
f"File size ({file_size_mb:.1f}MB) exceeds limit of {max_size_mb}MB"
)
if path.suffix.lower() not in self.SUPPORTED_EXTENSIONS:
raise ValueError(
f"Unsupported format: {path.suffix}. "
f"Supported: {', '.join(sorted(self.SUPPORTED_EXTENSIONS))}"
)
return path
def _cleanup_text(self, text: str) -> str:
"""清理文本
Args:
text: 原始文本
Returns:
str: 清理后的文本
"""
if self.config.text_cleanup['remove_extra_spaces']:
text = ' '.join(text.split())
View on GitHub (pinned to d6bde0fa54)
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).
Example fix
# before
for f in Path(folder).rglob('*'):
reader.read(f) # ValueError on .zip/.jpg sidecars
# after
ok = reader.SUPPORTED_EXTENSIONS
for f in Path(folder).rglob('*'):
if f.is_file() and f.suffix.lower() in ok:
reader.read(f) Defensive patterns
Strategy: type-guard
Validate before calling
ok = reader.SUPPORTED_EXTENSIONS
if Path(fp).suffix.lower() not in ok:
fp = convert_to(fp, target_ext='pdf') Type guard
def ext_supported(path: str, reader) -> bool:
from pathlib import Path
return Path(path).suffix.lower() in reader.SUPPORTED_EXTENSIONS Try / catch
try:
reader.read(fp)
except ValueError as e:
if str(e).startswith('Unsupported format'):
convert_then_retry(fp)
raise Prevention
- 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 ''.
When it happens
Trigger: 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.
Common situations: 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 ''.
Related errors
- 不支持的文件格式: {path.suffix}. 支持的格式: {', '.join(sorted(self.SUPPO
- 文件大小 ({file_size_mb:.1f}MB) 超过限制 {max_size_mb}MB
- 没有读取权限: {path}
- 文件大小 ({file_size_mb:.1f}MB) 超过限制 {max_size_mb}MB
- File not found: {path}
AI-assisted analysis of binary-husky/gpt_academic@d6bde0fa54 (2026-08-14).
Data as JSON: /api/errors/aa42cfdc31c327ff.
Report an issue: GitHub.