{"record":{"id":"1562ad74ee960504","repo":"docling-project/docling","slug":"cannot-convert-doc-with-self-document-hash-becau-1562ad","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":"DocumentLoadError","httpStatus":null,"severity":"error","filePath":"docling/backend/ebcdic_backend.py","lineNumber":272,"sourceCode":"    @override\n    def is_valid(self) -> bool:\n        return bool(self.content)\n\n    @classmethod\n    @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.EBCDIC}\n\n    @override\n    def convert(self) -> DoclingDocument:\n        \"\"\"Parse the EBCDIC data into one table per record schema.\"\"\"\n        if not self.is_valid():\n            raise DocumentLoadError(\n                f\"Cannot convert doc with {self.document_hash} because the \"\n                \"backend failed to init.\"\n            )\n\n        origin = DocumentOrigin(\n            filename=self.file.name or \"file.ebc\",\n            mimetype=_MIME_TYPE,\n            binary_hash=self.document_hash,\n        )\n        doc = DoclingDocument(name=self.file.stem or \"file\", origin=origin)\n        if self.layout.description:\n            doc.add_text(label=DocItemLabel.TEXT, text=self.layout.description)\n\n        decoder = _FieldDecoder(\n            self.options.encoding, self.options.strip_control_characters\n        )\n        rows = _RecordParser(self.layout, decoder).parse(\n            self.content, self.options.max_records","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/docling-project/docling/blob/61d76f1ff3f8428065465889f7b4577da7df704c/docling/backend/ebcdic_backend.py#L254-L290","documentation":"EBCDICBackend.convert() raises DocumentLoadError when is_valid() is false, i.e. self.content is empty because __init__ failed to read any bytes from the document (the init failure itself is reported separately). This guard prevents convert() from producing an empty, misleading document from a backend that never loaded data.","triggerScenarios":"Calling convert() on an EBCDIC backend whose content is empty: a zero-byte file, a stream already consumed, or a read failure during __init__ that was swallowed upstream.","commonSituations":"Reusing a BytesIO that a previous conversion already read to EOF; uploading empty files through a service that maps init errors to warnings and still calls convert(); race conditions where the file is truncated/deleted between init and convert.","solutions":["Check backend.is_valid() (or document validity) before calling convert()","Verify the source file is non-empty before starting conversion","For streams, seek(0) or pass a fresh BytesIO per conversion"],"exampleFix":"# before\ndoc = backend.convert()\n\n# after\nif not backend.is_valid():\n    raise ValueError('EBCDIC source is empty; check the input file/stream')\ndoc = backend.convert()","handlingStrategy":"validation","validationCode":"if not backend.is_valid():\n    raise ValueError('EBCDIC backend has no content; input file/stream is empty')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never reuse a consumed BytesIO; seek(0) before each conversion","Treat is_valid() == False as a hard stop before convert()"],"tags":["ebcdic","state-machine","empty-input"],"backgroundTag":null,"analyzedSha":"61d76f1ff3f8428065465889f7b4577da7df704c","analyzedAt":"2026-08-14T23:53:18.727Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}