{"record":{"id":"f41ad06c9acb8c6f","repo":"PaddlePaddle/PaddleOCR","slug":"unsupported-format-ext-nsupported-formats-su","errorCode":null,"errorMessage":"Unsupported format: .{ext}\\nSupported formats: {supported}","messagePattern":"Unsupported format: \\.(.+?)\\\\nSupported formats: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"paddleocr/_doc2md/registry.py","lineNumber":47,"sourceCode":"        \"\"\"Register a converter class; can be used as a decorator.\"\"\"\n        for ext in converter_cls.supported_extensions:\n            self._ext_map[ext.lower().lstrip(\".\")] = converter_cls\n        for mime in converter_cls.supported_mimetypes:\n            self._mime_map[mime] = converter_cls\n        return converter_cls\n\n    def get_converter(self, file_path: Path) -> BaseConverter:\n        \"\"\"Return an appropriate converter instance for the given file path.\"\"\"\n        ext = file_path.suffix.lower().lstrip(\".\")\n        if ext in self._ext_map:\n            return self._ext_map[ext]()\n\n        mime_type, _ = mimetypes.guess_type(str(file_path))\n        if mime_type and mime_type in self._mime_map:\n            return self._mime_map[mime_type]()\n\n        supported = \", \".join(f\".{e}\" for e in sorted(self._ext_map.keys()))\n        raise ValueError(f\"Unsupported format: .{ext}\\nSupported formats: {supported}\")\n\n    def supported_extensions(self) -> list[str]:\n        return sorted(self._ext_map.keys())\n\n\n# Global singleton registry\ndefault_registry = ConverterRegistry()\n","sourceCodeStart":29,"sourceCodeEnd":55,"githubUrl":"https://github.com/PaddlePaddle/PaddleOCR/blob/2661c7c0ef5c613e8f93c6e93b2e052399f0f854/paddleocr/_doc2md/registry.py#L29-L55","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"from paddleocr._doc2md.registry import default_registry\n\npath = Path('report.doc')\n# before\nconv = default_registry.get_converter(path)  # ValueError: Unsupported format: .doc\n# after\nif path.suffix.lower().lstrip('.') not in default_registry.supported_extensions():\n    path = convert_doc_to_docx(path)  # e.g. via LibreOffice headless\nconv = default_registry.get_converter(path)","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom paddleocr._doc2md.registry import default_registry\n\ndef is_supported(path: str) -> bool:\n    ext = Path(path).suffix.lower().lstrip('.')\n    return ext in default_registry.supported_extensions()","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["doc2md","registry","file-format","validation","valueerror"],"backgroundTag":null,"analyzedSha":"2661c7c0ef5c613e8f93c6e93b2e052399f0f854","analyzedAt":"2026-08-14T20:17:30.180Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}