Skip to content

fix(docreader): cap ebooklib below 0.21 - #6206

Open
gouyu-hou wants to merge 1 commit into
Tencent:mainfrom
gouyu-hou:fix/ebooklib-cap
Open

gouyu-hou wants to merge 1 commit into
Tencent:mainfrom
gouyu-hou:fix/ebooklib-cap

Conversation

@gouyu-hou

Copy link
Copy Markdown
Contributor

Observed

EbookLib 0.21 (released 2026-11, requires-python >=3.10, no more six) changed write_epub: the EPUB 3 navigation document is no longer written into the archive, while the package OPF it writes still lists EPUB/nav.xhtml in the manifest. Every EPUB produced by 0.21 therefore references a file it never ships, and read_epub raises KeyError before a single chapter is read:

File "ebooklib\reader.py", line 203, in _load_manifest
    ei.content = self.read_file(zip_path.join(self.opf_dir, ei.file_name))
...
KeyError: "There is no item named 'EPUB/nav.xhtml' in the archive"

Minimal check on the same book object:

ebooklib 0.20 -> entries: ['mimetype', 'META-INF/container.xml', 'EPUB/content.opf', 'EPUB/text/chapter.xhtml', 'EPUB/toc.ncx', 'EPUB/nav.xhtml']
ebooklib 0.21 -> entries: ['mimetype', 'META-INF/container.xml', 'EPUB/content.opf', 'EPUB/text/chapter.xhtml', 'EPUB/toc.ncx']   # manifest still references EPUB/nav.xhtml

docreader declares ebooklib>=0.18 with no upper bound, so a fresh install — or any environment not pinned by uv.lock — gets 0.21, EPUBParser._parse_epub throws, and every EPUB silently degrades to the ZIP fallback. The contract test that says "ZIP fallback only for a missing navigation document" goes red:

Repro / verification

Before (ebooklib 0.21, fresh install per the unbounded specifier):

$ python -m pytest docreader/tests/test_epub_table_pipes.py -q
1 failed, 1 warning in 1.73s
E   AssertionError: True != False   # "trying ZIP fallback" logged for a valid EPUB

After (cap at <0.21; uv.lock already resolves 0.20):

$ python -m pytest docreader/tests/test_epub_table_pipes.py -q
2 passed, 2 warnings in 1.40s

uv lock --project docreader --check passes with the updated specifier, and the locked resolution is unchanged (0.20), so CI's uv sync --locked keeps installing exactly what it installs today — the cap only stops unpinned environments from picking up the broken 0.21.

EbookLib 0.21 (released 2026-11) changed write_epub: the EPUB 3
navigation document is no longer written into the archive, while the
package OPF still lists it in the manifest. Every EPUB produced by
0.21 therefore references EPUB/nav.xhtml without shipping it, and
read_epub raises KeyError before a single chapter is read:

    File "ebooklib
eader.py", line 203, in _load_manifest
      ei.content = self.read_file(zip_path.join(self.opf_dir, ei.file_name))
    ...
    KeyError: "There is no item named 'EPUB/nav.xhtml' in the archive"

docreader declares "ebooklib>=0.18" with no upper bound, so a fresh
install (or any environment not pinned by uv.lock) gets 0.21 and every
EPUB silently degrades to the ZIP fallback — the contract test
"ZIP fallback only for a missing navigation document" goes red:

  before (ebooklib 0.21, fresh install per the unbounded spec):
    $ python -m pytest docreader/tests/test_epub_table_pipes.py -q
    1 failed, 1 warning in 1.73s
    AssertionError: True != False   # "trying ZIP fallback" logged for a valid EPUB

  after (cap at <0.21, uv.lock resolves 0.20):
    $ python -m pytest docreader/tests/test_epub_table_pipes.py -q
    2 passed, 2 warnings in 1.40s

uv lock --project docreader --check passes; the locked resolution is
unchanged (0.20), CI keeps using uv sync --locked.
Copilot AI balanced review requested due to automatic review settings November 30, 2026 06:22

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants