PaddlePaddle/PaddleOCR · error · ValueError
Unsupported format: .{ext}\nSupported formats: {supported}
Error message
Unsupported format: .{ext}\nSupported formats: {supported} What it means
ConverterRegistry.get_converter raises ValueError when it cannot find a converter for a file: neither the lowercased file extension nor the guessed MIME type matches any registered converter. It is the entry-point guard of the doc2md converter registry (paddleocr/_doc2md/registry.py), and the message lists the actually supported extensions so the caller knows what is accepted.
Source
Thrown at paddleocr/_doc2md/registry.py:47
"""Register a converter class; can be used as a decorator."""
for ext in converter_cls.supported_extensions:
self._ext_map[ext.lower().lstrip(".")] = converter_cls
for mime in converter_cls.supported_mimetypes:
self._mime_map[mime] = converter_cls
return converter_cls
def get_converter(self, file_path: Path) -> BaseConverter:
"""Return an appropriate converter instance for the given file path."""
ext = file_path.suffix.lower().lstrip(".")
if ext in self._ext_map:
return self._ext_map[ext]()
mime_type, _ = mimetypes.guess_type(str(file_path))
if mime_type and mime_type in self._mime_map:
return self._mime_map[mime_type]()
supported = ", ".join(f".{e}" for e in sorted(self._ext_map.keys()))
raise ValueError(f"Unsupported format: .{ext}\nSupported formats: {supported}")
def supported_extensions(self) -> list[str]:
return sorted(self._ext_map.keys())
# Global singleton registry
default_registry = ConverterRegistry()
View on GitHub (pinned to 2661c7c0ef)
Solutions
- Check default_registry.supported_extensions() first and only feed files with a listed extension.
- Convert the document to a supported format externally first (e.g. .doc -> .docx with LibreOffice) and retry.
- If you are intentionally adding a format, register your own BaseConverter subclass with ConverterRegistry before calling get_converter.
Example fix
from paddleocr._doc2md.registry import default_registry
path = Path('report.doc')
# before
conv = default_registry.get_converter(path) # ValueError: Unsupported format: .doc
# after
if path.suffix.lower().lstrip('.') not in default_registry.supported_extensions():
path = convert_doc_to_docx(path) # e.g. via LibreOffice headless
conv = default_registry.get_converter(path) Defensive patterns
Strategy: validation
Validate before calling
from pathlib import Path
from paddleocr._doc2md.registry import default_registry
def is_supported(path: str) -> bool:
ext = Path(path).suffix.lower().lstrip('.')
return ext in default_registry.supported_extensions() Prevention
- Filter input files through supported_extensions() before submitting batches
- Pre-convert legacy formats (.doc, .rtf) to supported ones with LibreOffice headless
- Fail the whole batch early on one unsupported file rather than mid-run
When it happens
Trigger: Passing a file whose extension is not in default_registry._ext_map, e.g. .txt, .rtf, .pptx, .csv, or a file with no/odd extension whose MIME type is also unrecognized; calling get_converter(Path('notes.xyz')) on the default registry.
Common situations: Assuming the doc2md pipeline handles any document type; users feeding older Office formats (.doc vs .docx), images outside supported set, or files with uppercase/mangled extensions (extension IS lowercased, so that part is handled); passing a directory path.
Related errors
- File not found: {file_path}
- Invalid mode {mode}, must be one of ['union', 'small', 'larg
- translation values should be between 0 and 1
- scale values should be positive
- fileUrl and filePath are mutually exclusive.
AI-assisted analysis of PaddlePaddle/PaddleOCR@2661c7c0ef (2026-08-14).
Data as JSON: /api/errors/f41ad06c9acb8c6f.
Report an issue: GitHub.