{"record":{"id":"b4d652e8b84b7c27","repo":"microsoft/markitdown","slug":"file-conversion-failed-after-len-attempts-attem","errorCode":null,"errorMessage":"File conversion failed after {len(attempts)} attempts:","messagePattern":"File conversion failed after (.+?) attempts:","errorType":"exception","errorClass":"FileConversionException","httpStatus":null,"severity":"error","filePath":"packages/markitdown/src/markitdown/_markitdown.py","lineNumber":649,"sourceCode":"                        failed_attempts.append(\n                            FailedConversionAttempt(\n                                converter=converter, exc_info=sys.exc_info()\n                            )\n                        )\n                    finally:\n                        file_stream.seek(cur_pos)\n\n                if res is not None:\n                    # Normalize the content\n                    res.text_content = \"\\n\".join(\n                        [line.rstrip() for line in re.split(r\"\\r?\\n\", res.text_content)]\n                    )\n                    res.text_content = re.sub(r\"\\n{3,}\", \"\\n\\n\", res.text_content)\n                    return res\n\n        # If we got this far without success, report any exceptions\n        if len(failed_attempts) > 0:\n            raise FileConversionException(attempts=failed_attempts)\n\n        # Nothing can handle it!\n        raise UnsupportedFormatException(\n            \"Could not convert stream to Markdown. No converter attempted a conversion, suggesting that the filetype is simply not supported.\"\n        )\n\n    def register_page_converter(self, converter: DocumentConverter) -> None:\n        \"\"\"DEPRECATED: Use register_converter instead.\"\"\"\n        warn(\n            \"register_page_converter is deprecated. Use register_converter instead.\",\n            DeprecationWarning,\n        )\n        self.register_converter(converter)\n\n    def register_converter(\n        self,\n        converter: DocumentConverter,\n        *,","sourceCodeStart":631,"sourceCodeEnd":667,"githubUrl":"https://github.com/microsoft/markitdown/blob/fd239d5d2be43d9b68329730206b9312c7d5a388/packages/markitdown/src/markitdown/_markitdown.py#L631-L667","documentation":"During _convert_stream, every registered converter whose accepts() returned True is tried; each converter that raises is recorded in failed_attempts with its traceback and the stream is seeked back. If at least one converter attempted and all failed, a FileConversionException is raised aggregating those attempts — the per-attempt exceptions are on the exception object, not in the message.","triggerScenarios":"A file whose extension makes converters claim it (e.g. .docx, .xlsx) but whose content is corrupt, truncated, password-protected, or actually a different format; or all claiming converters hit their own missing-dependency/parse errors during convert().","commonSituations":"Zero-byte or partially uploaded files, Office documents saved with encryption, files with a wrong extension (renamed .zip to .docx), or several converters failing on a malformed structure so no result is ever produced.","solutions":["Iterate exc.attempts on FileConversionException — each entry holds the individual exception and converter traceback that pinpoints the real failure","Verify the file opens in its native application; test integrity (e.g. python -c \"import zipfile; zipfile.ZipFile('f.docx').testzip()\")","Re-download or re-save the source file if truncated or renamed","If an attempt shows MissingDependencyException, install the matching extra"],"exampleFix":"# before\nresult = md.convert(\"broken.docx\")  # FileConversionException(attempts=[...])\n\n# after\nfrom markitdown import FileConversionException\ntry:\n    result = md.convert(\"broken.docx\")\nexcept FileConversionException as e:\n    for att in e.attempts:\n        print(att.converter, \"->\", att.error)","handlingStrategy":"try-catch","validationCode":"import zipfile\n\ndef looks_like_valid_docx(path: str) -> bool:\n    return zipfile.is_zipfile(path) and zipfile.ZipFile(path).testzip() is None","typeGuard":null,"tryCatchPattern":"from markitdown import FileConversionException\n\ntry:\n    result = md.convert(path)\nexcept FileConversionException as e:\n    for attempt in e.attempts:\n        log.error(\"converter %s failed: %s\", attempt.converter, attempt.error)\n    # distinguish root cause: missing extra vs corrupt file, then route accordingly\n    raise","preventionTips":["Check file size > 0 and zip integrity before submitting Office files","Log e.attempts — the aggregated wrapper alone hides the real cause","Install all needed extras up front so dependency failures never become attempts"],"tags":["conversion","aggregate-error","corrupt-file"],"backgroundTag":null,"analyzedSha":"fd239d5d2be43d9b68329730206b9312c7d5a388","analyzedAt":"2026-08-14T15:47:51.745Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}