{"record":{"id":"e7bbcd86720de075","repo":"docling-project/docling","slug":"opendocument-backend-could-not-load-document-with","errorCode":null,"errorMessage":"OpenDocument backend could not load document with hash {document_hash}","messagePattern":"OpenDocument backend could not load document with hash (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/backend/opendocument_backend.py","lineNumber":143,"sourceCode":"    except ValidationError:\n        if _ODF_HREF_SCHEME_RE.match(href):\n            # Looks like an attempted absolute URL (has a scheme) that failed\n            # to parse, e.g. a malformed host. Don't guess by treating it as\n            # a filesystem path.\n            return None\n        return Path(href)\n\n\ndef _load_odf_document(\n    path_or_stream: BytesIO | Path, document_hash: str\n) -> OdfDocument:\n    \"\"\"Load an ODF document from a path or in-memory stream.\"\"\"\n    try:\n        if isinstance(path_or_stream, BytesIO):\n            return OdfDocument(path_or_stream)\n        return OdfDocument(str(path_or_stream))\n    except Exception as e:\n        raise RuntimeError(\n            f\"OpenDocument backend could not load document with hash {document_hash}\"\n        ) from e\n\n\nclass _OdfBaseBackend(DeclarativeDocumentBackend):\n    \"\"\"Shared loading / validation logic for ODT, ODS and ODP backends.\"\"\"\n\n    _odf_type: str = \"\"  # \"text\", \"spreadsheet\" or \"presentation\"\n\n    @override\n    def __init__(\n        self,\n        in_doc: InputDocument,\n        path_or_stream: BytesIO | Path,\n        options: OdsBackendOptions | None = None,\n    ) -> None:\n        if not _ODFDO_AVAILABLE:\n            raise ImportError(_INSTALL_HINT) from _ODFDO_IMPORT_ERROR","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/opendocument_backend.py#L125-L161","documentation":"RuntimeError raised by _load_odf_document when the odfdo OdfDocument constructor fails on either a BytesIO or a path input. It is the OpenDocument backend's equivalent of the docx DocumentLoadError, wrapping the original exception with the document hash for traceability.","triggerScenarios":"Constructing an ODT/ODS/ODP backend with a file that odfdo cannot parse: not a ZIP-based ODF package, a password-protected ODF file, or a corrupted archive.","commonSituations":"Office exports saved in older binary formats (.sdw, .sxc) or .doc renamed to .odt; encrypted LibreOffice documents; partial uploads.","solutions":["Verify the file with: unzip -l file.odt — a valid ODF file lists content.xml and META-INF/manifest.xml.","Re-save the document from LibreOffice in ODF format (and without encryption) and retry.","If the input is actually another format, detect it (python-magic) and route to the correct backend.","Catch the RuntimeError at ingest and quarantine the file."],"exampleFix":"# before\nbackend = OdtDocumentBackend(in_doc, path)  # RuntimeError: could not load\n\n# after\ntry:\n    backend = OdtDocumentBackend(in_doc, path)\nexcept RuntimeError as e:\n    logger.error('ODF load failed for %s', path)\n    backend = None","handlingStrategy":"try-catch","validationCode":"import zipfile\nwith zipfile.ZipFile(path) as z:\n    names = z.namelist()\nif 'content.xml' not in names or 'META-INF/manifest.xml' not in names:\n    raise ValueError('not a valid ODF package')","typeGuard":null,"tryCatchPattern":"try:\n    backend = OdtDocumentBackend(in_doc, path)\nexcept RuntimeError as e:\n    logger.error('ODF load failed (%s): %s', path, e)\n    quarantine(path)","preventionTips":["Sniff the ZIP structure of ODF uploads before conversion","Re-save legacy or encrypted ODF files from LibreOffice","Keep original exceptions via __cause__ for diagnostics"],"tags":["opendocument","odf","corrupt-file","load-failure"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}