fix: PDF tool accepts fractional page numbers that select no extracted pages#99582
fix: PDF tool accepts fractional page numbers that select no extracted pages#99582Linux2010 wants to merge 1 commit into
Conversation
parsePageRange used Number(part) which accepts fractional values like "1.5". The document-extract fallback later filters non-integer pages with Number.isInteger, silently dropping them and producing empty extraction results. Add Number.isInteger check at parse time to reject fractional input with a clear error. Closes openclaw#99393
|
Thanks for the context here. I swept through the related work, and this is now duplicate or superseded. Close this PR as superseded: it targets a real PDF page parser bug, but an earlier open, mergeable, proof-positive PR already covers the same parser boundary with stronger tool-boundary coverage and real behavior proof. Canonical path: Land one proof-positive parser-boundary fix, preferably #99399, then close the linked issue and the duplicate open fix candidates. So I’m closing this here and keeping the remaining discussion on #99399 and #99403. Review detailsBest possible solution: Land one proof-positive parser-boundary fix, preferably #99399, then close the linked issue and the duplicate open fix candidates. Do we have a high-confidence way to reproduce the issue? Yes at source level: current Is this the best way to solve the issue? No for this branch as the best landing path: the parser-boundary change is plausible, but #99399 already covers the same fix with stronger real behavior proof and tool-boundary coverage. Security review: Security review cleared: The diff tightens PDF parser validation and adds tests; it does not touch dependencies, workflows, secrets, package metadata, or supply-chain execution paths. AGENTS.md: found and applied where relevant. What I checked:
Likely related people:
Codex review notes: model internal, reasoning high; reviewed against 5342effebcf7. |
|
ClawSweeper applied the proposed close for this PR.
|
Closes #99393
What Problem This Solves
Fixes an issue where users of the
pdftool could pass fractional page numbers (e.g.pages: "1.5") that silently produced empty extraction results. The parser accepted fractional values viaNumber(part), but the document-extract fallback later filtered them out withNumber.isInteger(p), so the request continued with no selected PDF content instead of a clear input error.Why This Change Was Made
Added a
Number.isInteger(num)check to the single-page token path inparsePageRange, so fractional input is rejected at parse time with anInvalid page numbererror — consistent with how invalid ranges, zero, and negative values are already handled. The dash-range path already uses^\d+$regex matching, so it is unaffected.User Impact
Users who accidentally pass fractional page numbers to the
pdftool now get an immediate, clear error instead of a silently empty result. Integer page numbers and ranges continue to work unchanged.Evidence
parsePageRange("1.5", 20)andparsePageRange("1,1.5", 20)both throwInvalid page numbersrc/agents/tools/pdf-tool.helpers.test.tspass