Repository navigation
Adopt comicbox 5.2.2: 404 a reader page past the end - #962
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
ReaderPageViewraisesNotFoundwhenget_page_by_index()returnsNone, instead of serving an empty body.Why
comicbox 5.2.2 changed
get_page_by_index()to returnNonefor an index past the last page. Before, it raisedStopIteration, which surfaced as a 500.Codex turned that
Noneintob""and returned a200 image/jpeg. Both page routes,/api/v4/comics/<pk>/pages/<page>and the OPDS/opds/bin/c/<pk>/<page>/page.jpg, are wrapped incache_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 callsget_cover_page(), which 5.2.2 didn't change.Reviewer notes
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.b""and is served as before. OnlyNonebecomes a 404.?serve=imagepath calls pdffile'sread_full_pixmap_jpegdirectly and never reaches comicbox. It may still return a 500 past the end; I haven't checked.Testing
test_a_page_past_the_end_is_not_foundfailed before the fix (200 == 404) and passes now.make fix,make lintandmake tyare clean.make test-python: 1576 passed, 1 xfailed.🤖 Generated with Claude Code