Skip to content

Adopt comicbox 5.2.2: 404 a reader page past the end - #962

Merged
ajslater merged 2 commits into
developfrom
comicbox-5.2.2-page-past-end
Sep 30, 2026
Merged

ajslater merged 2 commits into
developfrom
comicbox-5.2.2-page-past-end

Conversation

@ajslater

Copy link
Copy Markdown
Owner

What

  • Bumps comicbox to 5.2.2 (and picopt to 6.8.2 in dev deps).
  • ReaderPageView raises NotFound when get_page_by_index() returns None, instead of serving an empty body.

Why

comicbox 5.2.2 changed get_page_by_index() to return None for an index past the last page. Before, it raised StopIteration, which surfaced as a 500.

Codex turned that None into b"" and returned a 200 image/jpeg. Both page routes, /api/v4/comics/<pk>/pages/<page> and the OPDS /opds/bin/c/<pk>/<page>/page.jpg, are wrapped in cache_control_2xx(public=True, max-age=<week>). So a client that asked for a missing page cached an empty image for a week. A 404 doesn't get that header.

The other 5.2.2 fix, extract_covers() deduplication, doesn't touch codex. Cover generation calls get_cover_page(), which 5.2.2 didn't change.

Reviewer notes

  • The web reader clamps pages to maxPage, so normal reading never hits this. The 404 appears when an OPDS client's templated page URL runs past the end, or when the page count in the database no longer matches the file.
  • A zero-byte page entry still comes back as b"" and is served as before. Only None becomes a 404.
  • Not covered here: the PDF ?serve=image path calls pdffile's read_full_pixmap_jpeg directly and never reaches comicbox. It may still return a 500 past the end; I haven't checked.

Testing

  • New test_a_page_past_the_end_is_not_found failed before the fix (200 == 404) and passes now.
  • make fix, make lint and make ty are clean.
  • make test-python: 1576 passed, 1 xfailed.

🤖 Generated with Claude Code

ajslater and others added 2 commits September 29, 2026 20:29
comicbox 5.2.2 made get_page_by_index() return None for an index past
the last page; before, it raised StopIteration, which surfaced as a 500.
The page view turned that None into b"" and served it as a 200
image/jpeg, and both page routes (v4 reader and OPDS) mark 2xx
responses public for a week, so clients kept the empty image.

Raise NotFound on None instead. cache_control_2xx leaves 404s
uncached.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@ajslater
ajslater merged commit dc24718 into develop Sep 30, 2026
9 checks passed
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.

1 participant