EPUB: a content document that cannot be read is skipped and the result is still SUCCESS with no error
Bug
When a chapter of an EPUB cannot be read, the converted document leaves it out, and the result is still SUCCESS with an empty errors list, so nothing tells the caller that the book is incomplete. If no chapter can be read, the result is an empty document, again with SUCCESS.
The EPUB backend skips each content document it cannot read with only a log warning (L499-L503).
Both inputs I used are invalid EPUBs: a damaged archive whose spine lists a file it does not contain, and a content document stored as ISO-8859-1 (EPUB 3.3 §3.9 requires UTF-8 or UTF-16; _decode_content_file, L364-L377, raises on it). The point is the false success, not support for such files. #4351 fixed the UTF-16 case of this skip and named the remaining silent loss as a wider change.
The backend has no channel for recoverable errors while returning a document: SimplePipeline._build_document takes only the document (L42-L44) and _determine_status always returns SUCCESS (L46-L50). BasePipeline.execute already turns SUCCESS into PARTIAL_SUCCESS when conv_res.errors is not empty (L106-L109).
The Word backend skips a footnotes or endnotes part it cannot parse the same way (L5075-L5078): a DOCX whose word/footnotes.xml is cut short converts with SUCCESS, no error and no footnotes.
Impact
convert() callers and the CLI get the book without the chapter and SUCCESS; --fail-on partial cannot catch it.
Steps to reproduce
import zipfile
from io import BytesIO
from docling.datamodel.base_models import DocumentStream
from docling.document_converter import DocumentConverter
# A damaged EPUB: the spine lists three chapters, the archive holds only two.
buffer = BytesIO()
with zipfile.ZipFile(buffer, "w") as z:
z.writestr("mimetype", "application/epub+zip")
z.writestr(
"META-INF/container.xml",
'<container version="1.0" xmlns="urn:oasis:names:tc:opendocument:xmlns:container"><rootfiles>'
'<rootfile full-path="content.opf" media-type="application/oebps-package+xml"/></rootfiles></container>',
)
items = "".join(f'<item id="c{i}" href="ch{i}.xhtml" media-type="application/xhtml+xml"/>' for i in (1, 2, 3))
spine = "".join(f'<itemref idref="c{i}"/>' for i in (1, 2, 3))
z.writestr(
"content.opf",
'<package xmlns="http://www.idpf.org/2007/opf" version="3.0"><metadata/>'
f"<manifest>{items}</manifest><spine>{spine}</spine></package>",
)
z.writestr("ch1.xhtml", "<html><body><p>Chapter one.</p></body></html>")
z.writestr("ch3.xhtml", "<html><body><p>Chapter three.</p></body></html>")
buffer.seek(0)
result = DocumentConverter().convert(DocumentStream(name="book.epub", stream=buffer))
print("status:", result.status.value)
print("errors:", [e.error_message for e in result.errors])
print("markdown:", repr(result.document.export_to_markdown()))
Output:
Failed to read content file ch2.xhtml: "There is no item named 'ch2.xhtml' in the archive"
status: success
errors: []
markdown: 'Chapter one.\n\nChapter three.'
Expected: PARTIAL_SUCCESS with an error naming ch2.xhtml. With none of the three chapters in the archive the result today is SUCCESS with markdown: ''; expected FAILURE, as #4332 does when every page of a VLM conversion fails.
Possible fix
Let a declarative backend record the errors it recovers from, and have SimplePipeline add them to conv_res.errors; the EPUB backend records each skipped content document and fails when none could be read. A PR with this change and tests follows.
Docling version
docling main at commit a7760abf (v2.150.0-17), docling-core 2.106.0; the line numbers above are from that commit. Also reproduced on the docling 2.150.0 release with docling-core 2.106.0.
Python version
3.12.13 (main), 3.14.4 (2.150.0 release)
Classification labels added: bug, priority:medium, epub, docx.
These labels are advisory. Maintainers can correct them. The workflow preserves these corrections.