{"record":{"id":"a8ddebc9c49d7dd1","repo":"docling-project/docling","slug":"cannot-convert-doc-with-self-document-hash-becau-a8ddeb","errorCode":null,"errorMessage":"Cannot convert doc with {self.document_hash} because the backend failed to init.","messagePattern":"Cannot convert doc with (.+?) because the backend failed to init\\.","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"docling/backend/opendocument_backend.py","lineNumber":1498,"sourceCode":"    @override\n    def supports_pagination(cls) -> bool:\n        return False\n\n    @classmethod\n    @override\n    def supported_formats(cls) -> set[InputFormat]:\n        return {InputFormat.ODT}\n\n    @override\n    def convert(self) -> DoclingDocument:\n        origin = DocumentOrigin(\n            filename=self.file.name or \"file\",\n            mimetype=\"application/vnd.oasis.opendocument.text\",\n            binary_hash=self.document_hash,\n        )\n        doc = DoclingDocument(name=self.file.stem or \"file\", origin=origin)\n        if not self.is_valid():\n            raise RuntimeError(\n                f\"Cannot convert doc with {self.document_hash} because the backend failed to init.\"\n            )\n\n        self._walk(self.odf_obj.body.children, parent=None, doc=doc)\n        return doc\n\n    def _walk(\n        self,\n        elements: list[Any],\n        parent: NodeItem | None,\n        doc: DoclingDocument,\n    ) -> None:\n        _add_odf_children(\n            doc,\n            elements,\n            parent=parent,\n            content_layer=None,\n            odf_obj=self.odf_obj,","sourceCodeStart":1480,"sourceCodeEnd":1516,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/opendocument_backend.py#L1480-L1516","documentation":"RuntimeError raised by OdtDocumentBackend.convert() when is_valid() is False — the shared _OdfBaseBackend constructor either failed to load the document (which usually raises earlier) or the validity flag was never set. It guards convert() against running on an uninitialized odf_obj body.","triggerScenarios":"Calling convert() on an ODT backend instance whose load path left self.valid False — e.g. subclass misuse, or code that swallows the constructor's RuntimeError and continues.","commonSituations":"Wrapper code that constructs backends in try/except and calls convert() unconditionally; race conditions where the file was deleted between construction and conversion.","solutions":["Check backend.is_valid() before convert().","Do not suppress constructor exceptions — let DocumentLoadError/RuntimeError from loading propagate instead of calling convert() on a broken backend.","Re-run with the source file present and readable for the whole conversion window."],"exampleFix":"# before\ndoc = backend.convert()\n\n# after\nif not backend.is_valid():\n    raise ValueError('ODT backend not initialized; load failed earlier')\ndoc = backend.convert()","handlingStrategy":"validation","validationCode":"if not backend.is_valid():\n    raise ValueError('ODT backend not initialized')","typeGuard":null,"tryCatchPattern":"if backend.is_valid():\n    doc = backend.convert()\nelse:\n    raise ValueError('ODT load failed; see constructor error')","preventionTips":["Check is_valid() before convert()","Never suppress backend constructor exceptions","Log the document_hash carried in backend state for tracing"],"tags":["odt","state-check","invalid-input"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}