{"record":{"id":"64fb00361c731062","repo":"docling-project/docling","slug":"conversion-failed-because-the-provided-file-has-no","errorCode":null,"errorMessage":"Conversion failed because the provided file has no recognizable format or it wasn't in the list of allowed formats.","messagePattern":"Conversion failed because the provided file has no recognizable format or it wasn't in the list of allowed formats\\.","errorType":"exception","errorClass":"ConversionError","httpStatus":null,"severity":"error","filePath":"docling/document_converter.py","lineNumber":589,"sourceCode":"                ConversionStatus.PARTIAL_SUCCESS,\n            }:\n                error_details = \"\"\n                if conv_res.errors:\n                    error_messages = [err.error_message for err in conv_res.errors]\n                    error_details = f\" Errors: {'; '.join(error_messages)}\"\n                # Chain the underlying exception (when one was captured during\n                # input construction) so callers can classify failures via\n                # ``__cause__`` — e.g. an encrypted PDF surfaces the original\n                # ``PdfiumError``. See issue #1920.\n                raise ConversionError(\n                    f\"Conversion failed for: {conv_res.input.file} with status: \"\n                    f\"{conv_res.status.value}.{error_details}\"\n                ) from get_input_rejection_cause(conv_res.input)\n            else:\n                yield conv_res\n\n        if not had_result and raises_on_error:\n            raise ConversionError(\n                \"Conversion failed because the provided file has no recognizable \"\n                \"format or it wasn't in the list of allowed formats.\"\n            )\n\n    @validate_call(config=ConfigDict(strict=True))\n    def convert_string(\n        self,\n        content: str,\n        format: InputFormat,\n        name: Optional[str] = None,\n    ) -> ConversionResult:\n        \"\"\"Convert a document given as a string using the specified format.\n\n        Only Markdown (`InputFormat.MD`), HTML (`InputFormat.HTML`), and DocLang\n        (`InputFormat.XML_DOCLANG`) formats are supported. The content is wrapped\n        in a `DocumentStream` and passed to the main conversion pipeline.\n\n        Args:","sourceCodeStart":571,"sourceCodeEnd":607,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/document_converter.py#L571-L607","documentation":"convert_all tracks whether any ConversionResult was yielded; if none was produced and raises_on_error is true, it raises ConversionError stating the file had no recognizable format or was not in the allowed formats. This happens when every input was rejected before conversion (format detection failed or the detected format is excluded by allowed_formats/format_options), so there is no per-file result to report.","triggerScenarios":"Calling convert() / convert_all() with raises_on_error=True on a file whose extension/content is unrecognized, or whose detected InputFormat is not among the converter's allowed_formats; an empty/garbage file; a misnamed extension confusing format detection.","commonSituations":"Uploading arbitrary user files without pre-filtering; allowed_formats narrowed to PDF while receiving images; files with wrong extensions or corrupt content.","solutions":["Pre-check the detected format with FormatToExtensions / docling's format detection and reject unsupported files with your own error message.","Widen allowed_formats / add format_options to cover the formats you actually accept.","Handle this ConversionError (or use raises_on_error=False) and report 'unsupported file type' to the user."],"exampleFix":"# before\nres = converter.convert(user_path)  # raises on unrecognized file\n\n# after\nfrom docling.datamodel.document import InputDocument\ntry:\n    res = converter.convert(user_path)\nexcept ConversionError as e:\n    raise HTTPException(415, \"Unsupported or unrecognized file format\") from e","handlingStrategy":"try-catch","validationCode":"from docling.datamodel.document import InputDocument\nfrom docling.core.utils import DocumentFormatToExtension  # if available; else check suffix\n\ndef detectable(path: Path, allowed: set[InputFormat]) -> bool:\n    fmt = detect_format(path)  # docling format detection\n    return fmt in allowed","typeGuard":null,"tryCatchPattern":"try:\n    result = converter.convert(path)\nexcept ConversionError as e:\n    if \"no recognizable format\" in str(e):\n        return unsupported_file_response(path)\n    raise","preventionTips":["Restrict uploads by extension/MIME type before invoking the converter.","Keep allowed_formats in sync with the file types your product actually accepts.","Give users a clear 'unsupported file type' message rather than a raw ConversionError."],"tags":["conversion","format-detection","document-converter","allowed-formats","validation"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}