fix: cap HTTP PDF response bodies - #20
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: blocked before merge. Reviewed September 4, 2026, 12:41 PM ET / 16:41 UTC. ClawSweeper reviewWhat this changesAdds a 100 MB HTTP(S) PDF response limit, configurable library and CLI overrides, typed budget errors, connection cleanup, documentation, and package-level coverage. Merge readiness⛔ Blocked before merge - 3 items remain Keep open for maintainer review: the patch correctly adds a bounded remote-PDF read path with documented escape hatches, but the new 100 MB default intentionally changes upgrade behavior for existing large remote inputs. Priority: P2 Review scores
Verification
How this fits togetherClawPDF normalizes local and remote PDF inputs before passing bytes to its PDFium engine for text extraction or rendering. This change bounds HTTP(S) input buffering while preserving local, blob, data-URL, and stdin behavior. flowchart LR
A[Remote PDF URL] --> B[Input normalizer]
C[Library or CLI byte limit] --> B
B --> D[Header size check]
D --> E[Streaming body counter]
E --> F[PDFium engine]
F --> G[Text or PNG output]
Decision needed
Why: The implementation is coherent, but choosing a new default that rejects previously successful large remote inputs is an upgrade-policy decision rather than a mechanical defect. Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Accept the 100 MB default only with explicit ownership of the upgrade contract, retain the documented library and CLI escape hatches, and call out the new default in the next release notes. Do we have a high-confidence way to reproduce the issue? Yes—current main visibly buffers successful remote responses without a size limit, and the introduced tests and package harness cover declared and streamed oversize responses. Is this the best way to solve the issue? Unclear—the streamed cap and escape hatches are a narrow implementation, but maintainers must first approve the 100 MB default as an intentional upgrade behavior. AGENTS.md: not found in the target repository. Codex review notes: model internal, reasoning high; reviewed against f356c4565305. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (9 earlier review cycles; latest 8 shown)
|
Signed-off-by: Sebastien Tardif <SebTardif@ncf.ca>
ebbca58 to
d5ca3a7
Compare
HTTP(S) PDF inputs previously buffered an unbounded response, so a fast oversized download could exhaust memory within the existing 30-second deadline. This adds a 100 MB default body budget, rejects oversized declared lengths (including values beyond safe-integer range), counts streamed bytes, and preserves
PdfBudgetErrorwithlimit=fetchMaxBytes.Library callers can set
fetchMaxBytes; CLI extraction and rendering accept--fetch-max-bytes <n>. Both support0to disable the cap, preserving an explicit path for large remote PDFs. Rejected HTTP status responses now abort their unread bodies and release connections. File, blob, data URL, and stdin bodies are not capped.The original implementation and commit are by @SebTardif (Sebastien Tardif). Maintainer follow-up adds CLI compatibility, connection cleanup, documentation/changelog, and installed-package coverage.
Validation:
pnpm build,pnpm typecheck,pnpm test(18 tests),pnpm test:package,pnpm docs:site, andpnpm pack --dry-runpass on Node 24. The package test installs the tarball and uses a real local HTTP server to exercise implicit/explicit extraction and rendering, numeric/disabled budgets, default rejection, invalid-argument exit codes, library text extraction, PNG bytes, and rejected-response connection closure. Its HTTP 503 cleanup check failed before the cancellation fix and passes afterward. Existing tests cover stalled headers/bodies and caller cancellation.A separate built-CLI proof used a valid 100,000,611-byte PDF: extraction and rendering rejected it by default, then produced valid text/PNG with an exact-size budget and with
0. Browser execution and multi-gigabyte downloads were not exercised. CI validates the supported Node 22/24/26 matrix. No release or deployment is included.