Skip to content

fix: page_number for form feeds inside a RecursiveDocumentSplitter chunk - #12590

Draft
dylanpulver wants to merge 1 commit into
deepset-ai:mainfrom
dylanpulver:fix-recursive-splitter-page-number
Draft

fix: page_number for form feeds inside a RecursiveDocumentSplitter chunk#12590
dylanpulver wants to merge 1 commit into
deepset-ai:mainfrom
dylanpulver:fix-recursive-splitter-page-number

Conversation

@dylanpulver

Copy link
Copy Markdown

Related Issues

None — found comparing how the splitters compute page_number.

Proposed Changes:

RecursiveDocumentSplitter counted every \f in a chunk before assigning its page_number, so a chunk got the page it ends on, not the page its text starts on.

A correction exists, but it only strips form feeds that are the chunk's very last characters (chunk.rstrip("\f")). With any separator other than "\f" the break is followed by the separator, so it never fires — "another page. \f " ends with a space.

page_number now comes from the chunk's start offset, already tracked for split_idx_start. Leading form feeds still advance the chunk's page, so that is unchanged.

"aa bb\fcc dd ee ff\fgg hh", split_length=4, separators=[" "], split_unit="word":

chunk before after
"aa bb\fcc dd ee " 2 1
"ff\fgg hh" 3 2

DocumentSplitter returns 1 and 2 for this text.

How did you test it?

New unit test for a break inside a chunk. hatch run test:unit test: 6360 passed before, 6361 after, no failures either side. fmt and test:types clean on the changed files.

Two existing assertions changed from 3 to 2, both on the chunk starting "another page." — that text is on page 2. The other four page assertions in each test are unchanged.

Notes for the reviewer

This PR was generated with an AI assistant (Claude Code, claude-opus-5). I reviewed the changes and ran the relevant tests.

The splitter counted every form feed in a chunk before assigning that
chunk's page_number, so a chunk was labelled with the page it ends on
rather than the page its text starts on. The existing correction only
applied when the form feed was the chunk's last character, which any
separator other than "\f" prevents.

page_number is now derived from the chunk's start offset in the source
document, which the component already tracks for split_idx_start.
@dylanpulver
dylanpulver requested a review from a team as a code owner September 3, 2026 17:04
@dylanpulver
dylanpulver requested review from anakin87 and removed request for a team September 3, 2026 17:04
@vercel

vercel Bot commented Sep 3, 2026

Copy link
Copy Markdown

@dylanpulver is attempting to deploy a commit to the deepset Team on Vercel.

A member of the Team first needs to authorize it.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@HaystackBot

Copy link
Copy Markdown
Contributor

Hi @dylanpulver, thanks a lot for your contribution! 🙏

We noticed that the Contributor License Agreement (CLA) check (license/cla) hasn't passed yet, so we've temporarily moved this PR to draft and paused the review assignment.

To get your PR reviewed, please sign the CLA via the link in the license/cla check below (or in the CLA bot comment). As soon as the check turns green, this PR will automatically be marked ready for review again and a reviewer will be re-assigned.

@HaystackBot
HaystackBot removed the request for review from anakin87 September 3, 2026 18:33
@HaystackBot HaystackBot added the cla-pending PR is in draft until the contributor signs the CLA label Sep 3, 2026
@HaystackBot
HaystackBot marked this pull request as draft September 3, 2026 18:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla-pending PR is in draft until the contributor signs the CLA topic:tests

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants