-
-
Notifications
You must be signed in to change notification settings - Fork 80.7k
[Bug]: PDF tool accepts fractional page numbers that select no extracted pages #99393
Copy link
Copy link
Closed
Closed
Copy link
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Description
Metadata
Metadata
Assignees
Labels
P2Normal backlog priority with limited blast radius.Normal backlog priority with limited blast radius.clawsweeper:fix-shape-clearClawSweeper found a clear likely implementation shape for this issue.ClawSweeper found a clear likely implementation shape for this issue.clawsweeper:queueable-fixClawSweeper marked this issue as an existing queue_fix_pr work candidate.ClawSweeper marked this issue as an existing queue_fix_pr work candidate.clawsweeper:source-reproClawSweeper found a high-confidence source-level issue reproduction.ClawSweeper found a high-confidence source-level issue reproduction.impact:data-lossCan lose, corrupt, or silently drop user/session/config data.Can lose, corrupt, or silently drop user/session/config data.issue-rating: 🦞 diamond lobsterVery strong issue quality with high-confidence source-level or clear reproduction.Very strong issue quality with high-confidence source-level or clear reproduction.no-staleExclude from stale automationExclude from stale automation
Type
Fields
Priority
None yet
Bug type
Behavior bug (incorrect output/state without crash)
Beta release blocker
No
Summary
The PDF tool accepts fractional
pagesvalues such as1.5as parsed page numbers, but the document extraction fallback later filters them out as non-integer pages, so the request can continue with no selected PDF content instead of a clear input error.Steps to reproduce
pdftool with a non-native PDF model path so extraction fallback is used.pages: "1.5".parsePageRange("1.5", 20)currently produces[1.5], while the document extractor only keeps integer page numbers.Expected behavior
The
pagesparameter should reject fractional page numbers with anInvalid page number-style error because the documented contract is 1-based page numbers and examples use integer pages/ranges.Actual behavior
Single-page tokens are parsed with
Number(part), so fractional values pass the PDF tool parser. Thedocument-extractplugin then filterspageNumberswithNumber.isInteger(p), which drops fractional pages before text/image extraction.OpenClaw version
Current
mainat4e6933c84f186235f467d73c8d73e0bb6f1968a2, source-level repro.Operating system
Not OS-specific.
Install method
Source checkout /
pnpm dev.Model
Not provider-specific; affects the PDF extraction fallback path.
Provider / routing chain
Not provider-specific; source-level PDF tool runtime path.
Additional provider/model setup details
Not applicable.
Logs, screenshots, and evidence
Relevant source evidence:
src/agents/tools/pdf-tool.helpers.ts:49documentsparsePageRangeas returning sorted, unique, 1-based page numbers.src/agents/tools/pdf-tool.helpers.ts:68parses single page tokens withNumber(part), which accepts"1.5".src/agents/tools/pdf-tool.ts:489passes parsedpageNumbersinto PDF extraction.extensions/document-extract/document-extractor.ts:68-71filtersrequest.pageNumberstoNumber.isInteger(p) && p >= 1 && p <= pdf.pageCount.docs/tools/pdf.md:72documentspagesas 1-based page numbers.node_modules/clawpdf/CHANGELOG.md:13describes the dependency API around one-based pages;node_modules/clawpdf/dist/document.js:209-210rejects non-integer page numbers.Source-level probe of the current parser behavior:
Duplicate search summary:
pdf pagesfound unrelated issue#77090.pdf pagesfound unrelated media-path PR#93848.PDF page range,PDF page number,parsePageRange,pdf-tool.helpers, andpdfMaxPagesfound no open blockers.#97698fixed empty out-of-range page selections before native PDF analysis, but does not cover fractional page numbers.Focused regression test idea:
src/agents/tools/pdf-tool.helpers.test.ts: assertparsePageRange("1.5", 20)throwsInvalid page number.src/agents/tools/pdf-tool.test.ts: assert a fallback PDF tool request withpages: "1.5"rejects before model completion.Impact and severity
Affected: users of the
pdftool who pass fractionalpagesvalues, especially in extraction fallback mode.Severity: Medium; this is an edge-case input bug, but it can produce an answer without the requested PDF page content instead of an actionable input error.
Frequency: Always for fractional single-page tokens accepted by
Number(part).Consequence: The user may receive a model answer based on no selected PDF page content, making PDF analysis misleading.
Additional information
Related merged PR: #97698 fixed a neighboring empty-selection bug for out-of-range pages. This report is narrower: fractional page tokens still pass the parser and are only dropped later by the document extractor.