fix(robustness): graceful per-page detection + clearer errors (agent-team review) - #3
Merged
Merged
Conversation
…/flatten/read errors From an agent-team robustness review + real-world QA. detect/make_fillable no longer refuse a whole document on the first image-only page: a scanned or error-throwing page is skipped with a warning and the rest is processed; ScannedPDFError is raised only when every page is image-only (Gate C preserved). Also: fill() rejects a list value on a non-multi-select field with a clear error (was a cryptic pypdf AttributeError); _inherited guards against a circular /Parent (was an infinite loop); read_fields skips a single malformed widget instead of aborting; flatten no-ops on a fieldless PDF. Bumps to 0.3.2. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
san64777
added a commit
that referenced
this pull request
Jun 9, 2026
…/flatten/read errors (#3) From an agent-team robustness review + real-world QA. detect/make_fillable no longer refuse a whole document on the first image-only page: a scanned or error-throwing page is skipped with a warning and the rest is processed; ScannedPDFError is raised only when every page is image-only (Gate C preserved). Also: fill() rejects a list value on a non-multi-select field with a clear error (was a cryptic pypdf AttributeError); _inherited guards against a circular /Parent (was an infinite loop); read_fields skips a single malformed widget instead of aborting; flatten no-ops on a fieldless PDF. Bumps to 0.3.2.
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.
Context
You asked: "if there's an image in a PDF it doesn't warn and skip it, it crashes - at least it should complete the next pages," and to re-review the code with the agent-team. This is the result of a real-world QA pass plus a 3-lens agent-team review (QA / PDF-engine / independent code review).
The reported bug (fixed)
detect()/make_fillable()raisedScannedPDFErroron the first image-only page, discarding every other page. A mostly-vector form with one scanned/image page (a cover page, an exhibit) got zero fields. This violated the best-effort detection contract (best-effort detection must degrade gracefully).Fix:
detect_manifestnow skips a scanned or error-throwing page withwarnings.warnand processes the rest.ScannedPDFErroris raised only when every page is image-only (so a genuinely scanned single-page doc still refuses - Gate C preserved). Verified: a vector/image/vector PDF now detects fields on the two vector pages and warns about the image page.Other issues the review found (fixed)
fill()with a list value on a non-multi-select field crashed with a cryptic pypdfAttributeError(a real bug in the guaranteed core, from the multi-select work) -> now a clearValueError._inheritedcould infinite-loop on a circular/Parentchain (malformed PDFs contain these) -> cycle guard added.read_fieldsaborted the whole read on one malformed widget -> now skips it with a warning, recovers the rest.flattenon a fieldless PDF raised a raw pypdf error -> now a no-op returning the input.Deferred (tracked in D020, out of scope per rule 5)
Typed PDF-open error family (corrupt/encrypted input), rotated-page placement (needs golden-harness),
build()duplicate-name collision, XFA-dropped warning, text/checkbox sub-pixel guard.Validation