Skip to content

Bump pypdf from 6.21.4 to 7.2.0 - #1500

Open
dependabot[bot] wants to merge 4 commits into
masterfrom
dependabot/pip/pypdf-7.2.0
Open

dependabot[bot] wants to merge 4 commits into
masterfrom
dependabot/pip/pypdf-7.2.0

Conversation

@dependabot

@dependabot dependabot Bot commented on behalf of github Dec 5, 2026

Copy link
Copy Markdown
Contributor

Bumps pypdf from 6.21.4 to 7.2.0.

Release notes

Sourced from pypdf's releases.

Version 7.2.0, 2026-11-26

What's new

Security (SEC)

Deprecations (DEP)

Performance Improvements (PI)

Bug Fixes (BUG)

Robustness (ROB)

Full Changelog

Version 7.1.1, 2026-11-18

What's new

Security (SEC)

Performance Improvements (PI)

Bug Fixes (BUG)

... (truncated)

Changelog

Sourced from pypdf's changelog.

Version 7.2.0, 2026-11-26

Security (SEC)

  • Limit memory for embedded files dictionary API (#4533)
  • Limit size of indexed color space lookup tables (#4532)
  • Avoid cmap data splitting before size validation (#4531)

Deprecations (DEP)

  • Deprecate encryption_key of ContentStream.write_to_stream (#4508)
  • Deprecate parse_filename_page_ranges (#4472)

Performance Improvements (PI)

  • Check inline image names against a set when listing page images (#4467)
  • Count duplicate form field names and radio states without rescanning (#4478)
  • Avoid copying the visited set for each nested outline item (#4455)
  • Fix cache evaluation for XMP data retrieval (#4380)
  • Stop copying the page text for every text fragment (#4463)
  • Look up PageObject.page_number in constant time (#4439)
  • Use a set for the AcroForm field check in merge() (#4447)

Bug Fixes (BUG)

  • Preserve merged content streams during encryption (#4477)
  • Escape the font name in generated text field appearances (#4489)
  • Keep the generation number of objects in incremental updates (#4484)
  • Keep the writer's state when used as a context manager (#4488)
  • Remove every part of a combined ObjectDeletionFlag (#4446)
  • Remove objects which only unreferenced objects use (#4426)

Robustness (ROB)

  • Fall back for unsupported RC4 key lengths (#4461)

Full Changelog

Version 7.1.1, 2026-11-18

Security (SEC)

  • Limit inline image size for known-size fallback path (#4460)
  • Optimize memory usage of ASCIIHexDecode whitespace removal (#4458)
  • Limit the overall page label size before employing a fallback (#4457)
  • Restrict cross-reference stream work/memory (#4456)

Performance Improvements (PI)

  • List image identifiers only once when iterating over page images (#4452)
  • Index named destinations when appending a document (#4360)
  • Decode PDFDocEncoding strings with str.translate instead of per-character concatenation (#4429)

Bug Fixes (BUG)

  • Reject zero-step slices in PageRange (#4404)
  • Label a page that lies between the /Limits of two page label kids (#4385)

... (truncated)

Commits
  • 1aa10ec REL: 7.2.0
  • ab0395b SEC: Limit memory for embedded files dictionary API (#4533)
  • da93da3 SEC: Limit size of indexed color space lookup tables (#4532)
  • 9cf6e8b SEC: Avoid cmap data splitting before size validation (#4531)
  • 7b6722e MAINT: Raise AssertionError in the unreachable branch of _content_stream_rena...
  • 0631768 BUG: Preserve merged content streams during encryption (#4477)
  • 52c3a2c BUG: Escape the font name in generated text field appearances (#4489)
  • 8e68ce8 ROB: Skip invalid entries in font encoding /Differences (#4433)
  • 92b5618 DEP: Deprecate encryption_key of ContentStream.write_to_stream (#4508)
  • 0d5f323 MAINT: Keep one implementation of repr_mimebundle (#4507)
  • Additional commits viewable in compare view

Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot show <dependency name> ignore conditions will show all of the ignore conditions of the specified dependency
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)

Bumps [pypdf](https://github.com/py-pdf/pypdf) from 6.21.4 to 7.2.0.
- [Release notes](https://github.com/py-pdf/pypdf/releases)
- [Changelog](https://github.com/py-pdf/pypdf/blob/main/CHANGELOG.md)
- [Commits](py-pdf/pypdf@6.21.4...7.2.0)

---
updated-dependencies:
- dependency-name: pypdf
  dependency-version: 7.2.0
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
@dependabot dependabot Bot added the Dependencies Pull requests that update a dependency file label Dec 5, 2026

@jonfroehlich jonfroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review of the pypdf 6.21.4 → 7.2.0 bump

Head reviewed: 7544c6d91138a7a0b5858ec9009504718c297752. Comment-only review.

No blocking findings. The bump is compatible with how this repo uses pypdf, and CI is green on this head. There is one narrow behaviour regression worth a small follow-up PR (finding 1) and a test gap that let it through (finding 2).

What was checked

  • API used here (PdfReader(path), .pages, pypdf.errors.PdfReadError, and PdfWriter().add_blank_page() / .write() in tests): unchanged. pypdf/errors.py is byte-identical between the two versions, and strict still defaults to False.
  • 7.0.0 breaking changes, none of which affect this repo:
    • Python 3.9 dropped; the image and CI run 3.13.
    • cryptography<43 dropped; requirements.txt pins 51.0.0.
    • Deprecated APIs removed; none are used here.
    • File identifiers written by PdfWriter are no longer deterministic; no test compares PDF bytes.
  • Encrypted PDFs behave the same on both versions: owner-password-only files (RC4 and AES, including AES-256) return their page count, and files that need a user password return None.
  • Security. Fourteen advisories published upstream between 2026-11-06 and 2026-11-26 are fixed only in 7.0.0–7.2.0; there is no 6.x backport. None has a CVE ID yet, and neither OSV nor the GitHub Advisory Database lists anything against 6.21.4, which is why a vulnerability audit reports nothing for either version. Three of them are on the reader path this site runs for an uploaded publication PDF: GHSA-5chg-c4f3-fw2p, GHSA-p3v2-r3fx-qpm6 and GHSA-59jv-x5x2-gg4c.

Tests

  • CI on this head: all five checks pass. The test job installed pypdf 7.2.0 and ran 1156 tests, OK (28 skipped).
  • Local: the full suite in Docker images built from the repo Dockerfile (Python 3.13.18, ImageMagick 6, Ghostscript 10, postgres:16), once at this head and once at the PR's base commit f62627e. Both give the same result. Eighteen tests errored in both for a reason in my setup (the image is built without media/, so the tracked placeholder images under media/images/ were missing); with those images mounted, their three modules pass on both (24 tests).
  • Page counts on real PDFs, 6.21.4 vs 7.2.0:
    • 219 deployed publication PDFs: every one gives the same count (3,894 pages in total), with no meaningful change in run time.
    • The four deployed PDFs larger than 75 MB (see finding 1): same count on both.
  • 368 damaged or unusual PDFs (truncated, bytes flipped, blocks zeroed, wrong startxref, broken page trees, encrypted), run through the real get_pdf_page_count on both versions: four differ, and all four are improvements. 6.21.4 let a TypeError escape the helper; 7.2.0 raises PdfReadError, so the helper returns None (py-pdf/pypdf#4437).

Findings

1. Should-fix (follow-up PR, not blocking): a PDF over 75 MB with a damaged cross-reference table now raises through get_pdf_page_count

7.2.0 bounds the cross-reference rebuild (py-pdf/pypdf#4450). When a file is larger than 75,000,000 bytes and its xref table has to be rebuilt, pypdf raises LimitReachedError. That class derives from PyPdfError, not PdfReadError, so except (PdfReadError, OSError, ValueError) in website/utils/fileutils.py does not catch it. The helper's docstring promises it returns None instead of raising, so that a bad PDF never blocks a save.

Reproduced on this head against the base commit, through the model and the management command:

base (6.21.4) head (7.2.0)
Publication.save() with a 76 MB PDF whose xref header is garbled saves, num_pages=2 raises LimitReachedError: Maximum xref rebuild input length exceeded: 76000736 > 75000000.
backfill_num_pages with that file behind one row completes raises at that row; the rows after it are not filled
Same damage on a 74 MB file num_pages=2 num_pages=2
Stand-alone reproduction (pypdf only)
import io, sys, pypdf
from pypdf import PdfReader

def build(stream_bytes, xref_header=None):
    """A 2-page PDF padded with four streams; optionally with a garbled xref header."""
    objs = {1: b"<< /Type /Catalog /Pages 2 0 R >>",
            2: b"<< /Type /Pages /Kids [3 0 R 4 0 R] /Count 2 >>",
            3: b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] >>",
            4: b"<< /Type /Page /Parent 2 0 R /MediaBox [0 0 612 792] >>"}
    for i in range(4):
        objs[5 + i] = b"<< /Length %d >>\nstream\n" % stream_bytes + b"\0" * stream_bytes + b"\nendstream"
    out, offs = io.BytesIO(), {}
    out.write(b"%PDF-1.4\n")
    for n in sorted(objs):
        offs[n] = out.tell()
        out.write(b"%d 0 obj\n" % n + objs[n] + b"\nendobj\n")
    xref, size = out.tell(), max(objs) + 1
    out.write(xref_header or b"xref\n0 %d\n" % size)
    out.write(b"0000000000 65535 f \n" + b"".join(b"%010d 00000 n \n" % offs[i] for i in range(1, size)))
    out.write(b"trailer\n<< /Size %d /Root 1 0 R >>\nstartxref\n%d\n%%%%EOF\n" % (size, xref))
    return out.getvalue()

for label, each in (("74 MB", 18_500_000), ("76 MB", 19_000_000)):
    path = f"{sys.argv[1]}/damaged_{label[:2]}MB.pdf"
    open(path, "wb").write(build(each, xref_header=b"xref\n0 /9\n"))
    try:
        print(pypdf.__version__, label, "->", len(PdfReader(path).pages), "pages")
    except Exception as e:
        print(pypdf.__version__, label, "->", type(e).__name__, e)
6.21.4 74 MB -> 2 pages
6.21.4 76 MB -> 2 pages
7.2.0 74 MB -> 2 pages
7.2.0 76 MB -> LimitReachedError Maximum xref rebuild input length exceeded: 76000736 > 75000000.

Scope and context:

  • It takes both conditions: a file over 75 MB and a damaged xref table. Intact large files are unaffected, and none of the deployed PDFs tested changes.
  • A milder form of the same limit: a 76 MB file with stray bytes before %PDF, or a damaged startxref on a real 85 MB paper, now returns None where 6.21.4 returned the count. That one degrades as designed; the page count is simply left empty.
  • The change arrived in 7.2.0 itself; 7.0.0 through 7.1.1 still return the count.
  • The hole in the helper's contract is older than this PR. On the base commit, save() already raises for a PDF with a non-Standard security handler (NotImplementedError) and for a page tree more than 100 levels deep (LimitReachedError). Across the 368 damaged or unusual files above, seven escape the helper on 6.21.4 and three on 7.2.0, so the bump narrows the gap overall while adding this one case.
  • Not verified: I reproduced save() raising, not the admin form itself. A server error on save is what I would expect from it.

Suggested fix, in its own PR: catch Exception in get_pdf_page_count (the docstring already says no PDF should block a save), or at least (PyPdfError, NotImplementedError, OSError, ValueError). I ran both variants over those files and the over-75 MB cases on this head, and nothing escapes either.

2. Should-fix: the tests would not catch a parsing regression from a pypdf bump

Finding 1 passes CI. I mutated the page-count path to see what the suite pins down.

Caught: a count that is off by one, dropping PdfReadError from the except, returning 0 instead of None for a corrupt file, and the save and backfill logic (never filling, overwriting a manual count, writing during --dry-run).

Not caught, individually by the two page-count modules and all together by the full suite:

  • opening with PdfReader(path, strict=True);
  • returning the page tree's /Count instead of walking the pages;
  • dropping OSError and ValueError from the except;
  • removing .lower() from the .pdf extension check.

The cause is the fixtures: blank PDFs written by pypdf itself, one hand-built three-page PDF, and a stub that is not a PDF. Nothing exercises a PDF that needs lenient recovery, an encrypted PDF, or an exception from pypdf other than PdfReadError. With pip updates now checked daily and five pypdf releases in November, three small tests would cover most of it:

  • a PDF with a wrong startxref still returns its count (pins lenient mode);
  • an owner-password AES-256 PDF returns its count (this also pins the cryptography requirement, which today is guarded only by a comment in requirements.txt; without that package, pypdf raises DependencyError, which the helper does not catch either);
  • the helper returns None when pypdf raises LimitReachedError or NotImplementedError (a roughly 400-byte hand-built PDF with an unknown /Filter in its /Encrypt dictionary does the latter).

3. Nit: the release notes in the PR description are not a complete list of changes

  • Dependabot's excerpt is cut off before 7.0.0, the release with the breaking changes listed above.
  • The upstream changelog itself leaves commits out. 7.1.1...7.2.0 contains 57 commits, 18 tagged BUG and 12 tagged ROB; the changelog lists 6 and 1. Both behaviour changes found here (py-pdf/pypdf#4450 and py-pdf/pypdf#4437) are absent from it.

What the description does say matches upstream.

4. Nit: the branch is behind master

master has moved on since the PR's base (f62627e), but not in requirements.txt, so there is no conflict.

Second review: Gemini 4 Neon (XHigh) (gemini-4-neon-xhigh)

  • 0 findings.
  • It reviewed the 13-line diff only, without running anything.
  • In its reasoning it weighed one concern and dropped it as speculative: that a major release might raise the minimum Python version or remove deprecated APIs. The concern is right in substance, since 7.0.0 does both, but it does not apply here (Python 3.13, no removed API in use, as checked above). Rejected as a defect.
  • At one point its reasoning read the change as editing only a comment and not the pin. That is wrong, since the diff changes the active pypdf== line, and its later reasoning treats it as a real version bump.
  • The captured reasoning has about 4.6 KB cut from its middle by the capture tool, so I could not read that part.
  • It did not reach findings 1 or 2, which need the code to be run.
  • No follow-up.
  • Files excluded: none.

Review by Claude Fable 5.2 (claude-fable-5-2), with a second, independent review by Gemini 4 Neon (XHigh) (gemini-4-neon-xhigh) via the Google Antigravity CLI.

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

…1500)

pypdf 7.2.0 raises LimitReachedError (a PyPdfError, not a PdfReadError)
when it has to rebuild the xref of a damaged PDF over 75 MB, so
get_pdf_page_count let it escape and Publication.save() and
backfill_num_pages raised. NotImplementedError (non-Standard security
handler) and DependencyError (AES without cryptography; a bare Exception
subclass, so catching PyPdfError would still miss it) escaped the same
way before this bump.

The helper's contract is that a PDF never blocks a save, so it now
catches Exception and logs the exception type with the message.

Tests kill the mutants review 1 found surviving: strict=True (a PDF with
a stale startxref), reading the declared /Count instead of walking the
page tree, dropping OSError/ValueError from the except, and dropping
.lower() from the extension check. Also: an owner-password AES-256 PDF
is counted (fails if cryptography is missing), an unsupported security
handler returns None, and save() and the backfill survive a
LimitReachedError. All fixtures are built in the test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@jonfroehlich

Copy link
Copy Markdown
Member

Fix round 1: response to review 1

New head: 8a67e11. I reproduced each finding before changing anything.

Finding 1, a damaged PDF over 75 MB raises through get_pdf_page_count: fixed in this PR

The review suggested a follow-up PR. The fix is in this PR instead, because this bump introduces the regression and the fix is small. Merging the bump on its own would ship the regression.

Reproduced. I ran the review's 74 MB and 76 MB fixtures (garbled xref header) through the real helper in the repo's Docker image (pypdf 7.2.0, Python 3.13.18):

before the fix after the fix
74 MB damaged 2 2
76 MB damaged raises LimitReachedError: Maximum xref rebuild input length exceeded: 76000736 > 75000000. None, plus a warning in the log

Change. get_pdf_page_count in website/utils/fileutils.py now catches Exception and logs <name>: <ExceptionType>: <message>. The log line is the same as before, with the exception type added. The now-unused PdfReadError import is removed, and the docstring says why the catch is broad.

Why Exception and not (PyPdfError, NotImplementedError, OSError, ValueError):

  • DependencyError (AES without cryptography) is not a PyPdfError. In pypdf/errors.py it subclasses Exception directly, so the narrower tuple would still let it through.
  • pypdf has already let other types out. As the review found, 6.21.4 raised TypeError from this same helper. Any list of exception types would break again on some future release.
  • The docstring promises that a PDF never blocks a save, and the page count is only a convenience. When reading fails, num_pages stays empty for an editor to fill in, and the warning shows the exception type. Bugs in the helper itself still surface in tests, because the tests assert the return values.
  • The broad catch does not hide a missing cryptography package. A test now fails if it is missing (finding 2).

Finding 2, the tests didn't pin parsing behaviour: fixed in the same commit

Every fixture is built inside the test, either by hand or with PdfWriter. No binary files are committed, and nothing large is built: LimitReachedError is produced by mocking PdfReader.

New tests:

  • In website/tests/test_pdf_render.py, PdfPageCountTests, using SimpleTestCase and real PDF bytes:
    • a stale startxref still returns the count;
    • a page tree that declares /Count 9 but holds 3 pages returns 3;
    • an owner-password AES-256 PDF is counted;
    • /Encrypt << /Filter /FooSec >> returns None, where pypdf raises NotImplementedError;
    • PAPER.PDF is counted.
  • In website/tests/test_publication.py:
    • in GetPdfPageCountTests (SimpleTestCase):
      • a directory as the path returns None (a real OSError);
      • one subtest per exception type that PdfReader might raise: PdfReadError, LimitReachedError, PyPdfError, NotImplementedError, DependencyError, OSError, ValueError, TypeError, KeyError and RecursionError. Each must give None and a warning that names the type.
    • in the DatabaseTestCase classes, with LimitReachedError mocked:
      • Publication.save() succeeds and leaves num_pages empty;
      • backfill_num_pages still fills the other rows.

Tests fail before the fix. On the previous head, the new tests produced 3 failures and 10 errors. They covered the save and backfill regressions, the FooSec file, and every exception type outside the old tuple. The 3 failures are the PdfReadError, OSError and ValueError subtests, which only fail the new requirement that the log line name the exception type.

Mutation table. Each mutant was applied to the fixed fileutils.py, then test_pdf_render and test_publication were run (39 tests):

Mutant Survived review 1? Result Killed by
PdfReader(path, strict=True) yes killed test_wrong_startxref_is_recovered
return root_object['/Pages']['/Count'] instead of len(reader.pages) yes killed test_counts_page_tree_not_declared_count
except (PdfReadError, ValueError), no OSError yes killed test_returns_none_when_path_is_unreadable, plus subtests
except (PdfReadError, OSError), no ValueError yes killed test_returns_none_for_any_pypdf_failure (ValueError), plus others
.endswith('.pdf') without .lower() yes killed test_uppercase_extension_is_counted
except (PdfReadError, OSError, ValueError), the code before this fix n/a (the bug) killed save, backfill, FooSec, and 7 subtests
except (PyPdfError, NotImplementedError, OSError, ValueError), the review's narrower option n/a killed subtests DependencyError, TypeError, KeyError, RecursionError
warning without the exception type n/a killed all 10 subtests
cryptography uninstalled from the image (an environment mutant) n/a killed test_owner_password_aes256_pdf_is_counted ("cryptography is missing, so AES PDFs can't be read")

Environment. Tests ran in a Docker image built from the repo Dockerfile at the PR head (Python 3.13.18, pypdf 7.2.0, ImageMagick 6, Ghostscript), with the fixed website/ mounted in and a throwaway postgres:16. The full suite, python manage.py test website --settings=makeabilitylab.settings_test, ran with the tracked media/ present: 1165 tests, OK (28 skipped).

Finding 3, the changelog in the PR description is incomplete: no change

Agreed. Dependabot writes that text, and the upstream changelog itself leaves out py-pdf/pypdf#4450 and py-pdf/pypdf#4437. Review 1 already records what the description lacks, and editing Dependabot's description adds nothing to that.

Finding 4, the branch is behind master: no change

Agreed. master has not touched requirements.txt or the files changed here, so there is no conflict, and CI runs on the merge ref. I did not rebase the branch, since that would mean force-pushing it.

🤖 Generated with Claude Code — Opus 5.5, claude-opus-5-5

@jonfroehlich jonfroehlich left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Review 2: the fix round on the pypdf 6.21.4 → 7.2.0 bump

Head reviewed: 8a67e11084cc57f2648f6f7920c4cc3195c9c1a4 (one commit after 7544c6d, the head of review 1). Comment-only review of the diff 7544c6d..8a67e11 and the code around it.

No blocking findings. Review 1's regression is fixed, the fix broke nothing I could find, and the mutants that survived in review 1 are now killed. The new tests still let a few mutants through: one should-fix and three nits, all about tests. None of them is a defect in the shipped code.

1. Are review 1's findings closed?

Finding 1 (a damaged PDF over 75 MB raises through get_pdf_page_count): closed. I checked it with real bytes, using review 1's 76 MB fixture, because the PR's own tests mock the error.

helper before the fix, pypdf 7.2.0 this head, pypdf 7.2.0
helper, 76 MB damaged file raises LimitReachedError None, with a warning
Publication.save() with that file raises saves, num_pages left empty
backfill_num_pages with that file behind one row raises at that row skips it and fills the other row
helper, 74 MB damaged file 2 2

Not verified: the admin form end to end. Review 1 had the same gap.

Finding 2 (tests did not pin parsing behaviour): mostly closed. The three tests review 1 asked for are there, and all four of its surviving mutants are now killed. What remains is findings A to C below.

Findings 3 and 4 needed no change. Finding 4 has moved on; see finding D.

2. Did the fixes break anything?

No.

  • The try body is unchanged. Only the except clause and the log line differ, so every input that returned a count or None before still does, and the inputs that raised now return None.
  • Nothing else in the repo references the removed PdfReadError import or parses the old log text.
  • Full suite at this head: 1165 tests, OK (28 skipped). It ran in a Docker image built from the repo Dockerfile (Python 3.13.18, pypdf 7.2.0, cryptography 51.0.0) with a throwaway postgres:16. There were no failures, so nothing needed re-running on the base commit.
  • CI at this head: all five checks pass. The test job installed pypdf 7.2.0 and ran 1219 tests, OK (28 skipped).
  • The two changed test modules also pass on pypdf 6.21.4 (39 of 39), so the new tests are not tied to 7.2.0.

The claims in the fix-round answer that I re-ran all hold:

  • 3 failures and 10 errors when the new tests run against the helper before the fix;
  • 39 tests in the two modules;
  • 1165 tests OK (28 skipped) for the full suite;
  • DependencyError subclasses Exception directly;
  • all nine rows of its mutation table, including the one with cryptography uninstalled.

3. Mutation check

Each mutant was applied to this head, then test_pdf_render and test_publication were run (39 tests).

Killed (12):

  • PdfReader(path, strict=True);
  • returning the declared /Count;
  • except without OSError;
  • except without ValueError;
  • the extension check without .lower();
  • the except tuple from before the fix;
  • review 1's narrower tuple;
  • the warning without the exception type;
  • cryptography uninstalled;
  • the warning logged at info level;
  • returning 0 instead of None;
  • re-raising after the warning.

Survived (6):

Mutant Finding
len(reader.pages) moved out of the try A
continue → break in the backfill loop, in one row order only B
except narrowed to a tuple of the tested types' base classes C
the warning without the exception message C
the warning without the file name C
except BaseException C

Four more survive but either change nothing observable or sit in code older than this range: dropping the storage.exists check, dropping the if page_count: guard in save(), turning a zero count into None, and dropping the skip guard in the backfill.

Findings

A. Should-fix (tests, not blocking): nothing covers a failure raised while walking the page tree

  • Defect. Every failure the tests inject comes from the PdfReader(...) constructor: the mock's side_effect, the FooSec file and the stub file. pypdf reports page-tree problems later, from len(reader.pages).
  • Reproduce. Narrow the try to the constructor line and return len(reader.pages) after it. All 39 tests pass.
  • Why it matters. A hand-built PDF with 110 nested /Pages nodes (about 10 KB) opens without error and then raises LimitReachedError from len(reader.pages), on both 6.21.4 and 7.2.0. Review 1 listed this case among those that escaped the helper on the base commit. This head handles it correctly and returns None; only the test is missing.
  • Fix, verified. Either that fixture or a mocked reader whose .pages raises kills the mutant.

B. Nit: test_unreadable_pdf_does_not_stop_the_backfill catches a quiet stop in only one row order

  • Defect. The command's queryset has no ordering. With continue changed to break, the test passes whenever the readable row is visited first. Its docstring says "whatever order the command visits them in", which is true for a raise but not for a quiet stop.
  • Reproduce. The break mutant survived one of seven runs. Forcing the order makes it deterministic: with order_by("-pk") added to the command the mutant survives, and with order_by("pk") it is killed.
  • Fix, verified. Make the reader raise on its first call, whichever file that is, then assert that exactly one of the two rows is left empty. That kills the mutant in every order I forced.

C. Nit: "any exception" and the warning text are only partly pinned

  • Defect.
    • An except tuple that lists the base classes of the ten tested types passes every test, so a type outside it would escape unnoticed.
    • The warning can lose the exception message, or the file name, and every test still passes.
    • except BaseException passes too.
  • Reproduce. Apply any of those four changes to the helper and run the two modules: 39 of 39 pass.
  • Fix, verified. One more case that raises a locally defined Exception subclass and asserts the file name and the message in the log line kills the first three. An assertRaises(KeyboardInterrupt) case kills the last.

D. Nit: the green CI on this head predates recent dependency bumps on master

  • Defect. The answer's statement that master had not touched requirements.txt was true when written. Since then master has changed three pins there: django-debug-toolbar 8.0.0, django-prose-editor 0.30.0 and django-js-asset 5.0.0. CI on this head ran against the older master.
  • Reproduce. Compare the merge commit named in the test job's checkout step with master.
  • What I checked. I put this PR's four files on top of master at a643f99, built a fresh image and ran the full suite: 1226 tests, OK (28 skipped). master has gained 27 more commits since. None of them touches requirements.txt or the files in this PR, and I did not test against them. GitHub reports the PR as mergeable; the branch is 45 commits behind.

Second review: Gemini 4 Neon (XHigh) (gemini-4-neon-xhigh)

Two findings, from reading the diff 7544c6d..8a67e11 only (3 files, 238 lines), without running anything. Files excluded: none. Untracked files included: none. I tested both.

# Finding (file, quote) Severity if true Verdict
1 website/tests/test_pdf_render.py, self.assertIsNone(self._count(foo)): test_unsupported_security_handler_returns_none asserts only the None return and never confirms that pypdf raised NotImplementedError. nit Confirmed
2 website/tests/test_publication.py, bad = self._make_legacy_pub("Bad", 3): test_unreadable_pdf_does_not_stop_the_backfill has one good row beside the bad one, so it does not verify that the loop continues when the good row is visited first. nit Confirmed; same as finding B
  • Finding 1, reason. Today the fixture does raise NotImplementedError: on the helper before the fix, this test errors with exactly that. But the assertion cannot tell. I swapped in a truncated copy of the same file, which fails with a stream error instead, and the test's own assertion still passed. The proposed fix works: wrapping the call in assertLogs and asserting NotImplementedError in the log line passes on the real fixture and fails on the truncated one. A nit because the helper's contract, returning None, is still tested either way.
  • Finding 2, reason. Reproduced as in finding B. Its proposed fix, a good row before and after the bad one, kills the break mutant in ascending and descending key order. It is not fully order-proof: with the bad row visited last the mutant survives again, and I reproduced that by forcing such an order. The first-call variant in finding B kills it in all three orders.
  • It did not reach finding A, C or D, which need the code to be run.
  • Concerns it weighed and dropped in its reasoning, all correctly:
    • that the startxref test depends on exact byte formatting;
    • that a small offset shift might be tolerated without a rebuild. The strict=True mutant fails that test, so the fixture does exercise recovery;
    • whether pypdf counts from /Count or from the page tree.
  • The captured reasoning has about 50 KB cut from its middle by the capture tool, so I could not read that part.
  • No rebuttal was needed, since neither finding was rejected.

The second-review findings are by gemini-4-neon-xhigh via the Google Antigravity CLI. The triage and verdicts are mine.

🤖 Generated with Claude Code — Fable 5.2, claude-fable-5-2

jonfroehlich and others added 2 commits December 5, 2026 11:03
- A: a PDF whose page tree is nested past pypdf's 100-level limit opens
  fine and then raises LimitReachedError from len(reader.pages). Test it,
  so the try cannot shrink back to the PdfReader() call alone.
- B: the backfill test made the first PDF read fail, whichever row that
  is, and checks the other row is filled, so a loop that stops quietly
  fails the test in any row order.
- C: an exception type nobody listed is caught, the warning must carry
  the file name and the message as well as the type, and
  KeyboardInterrupt is not swallowed.
- Gemini 1: the FooSec test asserts that NotImplementedError was the
  failure, not just that None came back.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Brings in master's newer dependency pins (django-debug-toolbar,
django-prose-editor, django-js-asset) so CI runs this PR against them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

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

Dependencies Pull requests that update a dependency file

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant