Skip to content

Fix ingestion pipeline child delimiter extra newline - #18490

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-ingestion-pipeline-child-delimiter-extra-newline
Aug 19, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-ingestion-pipeline-child-delimiter-extra-newline

Conversation

@wangq8

@wangq8 wangq8 commented Aug 19, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@wangq8
wangq8 requested a review from xugangqiang August 19, 2026 05:10
@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Aug 19, 2026
@wangq8 wangq8 added the ci Continue Integration label Aug 19, 2026
@coderabbitai

coderabbitai Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 212bc98f-ccaa-4956-8488-760ebde05f0f

📥 Commits

Reviewing files that changed from the base of the PR and between 76111cb and ad82c02.

📒 Files selected for processing (2)
  • internal/ingestion/component/chunker/token.go
  • rag/flow/chunker/token_chunker.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The Go and Python token chunkers now remove one leading newline from the Mom or mom metadata assigned to child chunks produced by secondary delimiter splitting.

Changes

Child chunk parent metadata

Layer / File(s) Summary
Normalize Mom values across child split paths
internal/ingestion/component/chunker/token.go, rag/flow/chunker/token_chunker.py
Child chunk parent identifiers now strip one leading newline. The Go splitter continues to split the original chunk text.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Merge Risk: ⚪ Minimal · up to ad82c

This localized change is merge-ready after normal checks and review; no actionable merge-blocking risk remains.

Possibly related PRs

Suggested labels: 🐞 bug

Suggested reviewers: xugangqiang

Poem

I nudge one newline from the nest,
So parent marks look clean and best.
Go and Python, side by side,
Send tidy chunks on every stride.
Hop, hop—metadata aligned! 🐇

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request has no description, so it does not include the required summary or background context. Add a Summary section that explains the extra newline issue, its impact, and how the changes normalize child chunk parent metadata.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the fix for the extra newline in the ingestion pipeline child delimiter behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@wangq8 wangq8 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. The direction is correct and the Go/Python change is symmetric (strings.TrimPrefix(s, "\n") ≡ s.removeprefix("\n")), which keeps the two implementations in lock-step. A few things to confirm before merge:

1. Child text still keeps the leading \n (split source is untrimmed).
In splitByChildren you trim mom but still split the untrimmed text:

mom := strings.TrimPrefix(ck.Text, "\n")
parts := splitDroppingDelim(ck.Text, pattern) // still ck.Text, not mom

When the children delimiter is not "\n" itself (e.g. a sentence delimiter), the first child's Text still starts with "\n" while its Mom no longer does — so the parent reference and the child content now disagree about whether the leading newline exists. If the goal is to drop the extra leading newline everywhere, split from the trimmed value instead: parts := splitDroppingDelim(mom, pattern). (Python _split_chunk_docs_by_children has the same shape — splits the untrimmed chunk.get("text") — so parity is preserved either way; just please confirm the child text is intended to retain the "\n".)

2. The Go text-path change looks like a no-op.
Both callers of applyChildrenDelimText (chunkPerSegment and mergeByTokenSize) already strings.TrimSpace the parent before calling it, so t never has a leading "\n" and strings.TrimPrefix(t, "\n") never fires. The Python text path, by contrast, runs naive_merge (which prepends "\n" per paragraph) and does not trim before the children split, so the Python removeprefix("\n") is genuinely load-bearing. Net effect: this PR changes Python text-path output but leaves Go text-path output byte-identical. That asymmetry is fine (it actually closes an existing Go/Python gap), but the Go applyChildrenDelimText hunk reads as dead code — consider dropping it or adding a one-line comment explaining it's a defensive no-op.

3. TrimPrefix/removeprefix strip exactly one newline.
If a chunk can begin with multiple leading newlines ("\n\n..."), only the first is removed. In the merge path exactly one "\n" is prepended so this is safe, but it's worth a quick confirm that the JSON path (parser-provided item text) can't emit two.

4. Please add a regression test.
There's already token_children_delim_test.go asserting mom; a case where the parent text starts with "\n" (e.g. delimiters: ["\n"] + a children delimiter on the JSON path) would pin this behavior and prevent future regressions. The PR currently changes no tests.

Minor: the PR body is empty — a one-line description of the reproduction (which delimiter config leaks the newline into mom) would help reviewers and future maintainers.

(Note: I couldn't run the Go chunker tests locally — the package fails to build here due to a missing office_oxide.h cgo dependency, unrelated to this change.)

@codecov

codecov Bot commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (b27623a) to head (ad82c02).
⚠️ Report is 11 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #18490   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@wangq8
wangq8 merged commit 5f92323 into infiniflow:main Aug 19, 2026
8 checks passed
xugangqiang added a commit to xugangqiang/ragflow that referenced this pull request Aug 19, 2026
- Add TextBox.IsOCR and mark OCR-path boxes in processPageBoxes so
  layout.Dedup* only collapse OCR duplicates; char-path digital PDFs
  are never silently de-duplicated (review: dedup ran on all boxes
  with no source tag).
- Add TestMergeCaptions_FigureCaptionNoTargetKept and
  TestMergeTablesAcrossPages_PostMergeCleanup to lock the
  figure-caption no-target-keep branch and the cross-page merge
  post-cleanup combined call.
- Replace the all-or-nothing len(rowStrips)==len(rows) guard with
  matchRowStrip so header tables take the per-row strip override;
  add TestFillCellTextFromBoxes_RowStripHeaderTable.
- Move TestVMWhitespaceGapBridge out of the cgo&&manual tier into a
  CI-runnable unit test (vm_whitespace_bridge_test.go).
- Annotate known_diffs rule table-cell-fill-pre-vs-post-merge-order
  (14_text_table_interleaved, go_bug/open) as accepted_at_merge.

Review: PR infiniflow#18490/infiniflow#18516 points 2-5.
xugangqiang added a commit to xugangqiang/ragflow that referenced this pull request Aug 19, 2026
…up safety

- NaiveVerticalMerge: gate vertical merge on pageEnglish directly (mh=0)
  instead of the mh<=0 guard, which never fired for real English pages
  (their char-derived median height is always positive). Mirrors Python
  is_english -> chars=[] -> no merge; fixes eval_* line overflow in prod.
  Add TestVerticalMergeEnglishNoMergePositiveMedian (red->green).
- Extract parityLockedGridPDFs(); drop 13_crosspage_table and
  14_text_table_interleaved from the locked grid-parity set (both are
  known-unfixed content gaps — locking them contradicted accepted_at_merge).
  Add TestParityLockedGridExcludesUnfixed (CI-runnable).
- DedupSubstringOverlaps: bind the geometric containment test to the
  substring-text box (not just the shorter-height box) via boxInside, so a
  physically taller box whose short text is a substring of a neighbour is
  never silently dropped. Add TestDedupSubstringOverlaps_TallerFragmentKept.
- pipeline_parity_test.go: drop now-unused sort/lyt imports (left over from
  moving TestVMWhitespaceGapBridge out) so the manual harness compiles.

Review: PR infiniflow#18490/infiniflow#18516.
xugangqiang added a commit to xugangqiang/ragflow that referenced this pull request Aug 19, 2026
- vm_whitespace_bridge_test.go: drop the ~110-line hand-written vWithWS/vNoWS
  replica (production-vs-copy comparison can pass when both share a bias) and
  assert the literal production result: the whitespace gap bridge collapses
  the 4-box column to 1 section. Verified against mergeColumnBoxes
  (WS gap 14.00 < 14.04 threshold, OverlapX=1.0, then B/C cascade). Note: the
  review suggested 3; the actual production output is 1.
- pipeline_parity_test.go: count and print INTENTIONAL verdicts in the summary;
  loadPythonTables now distinguishes a missing vs corrupt Python tables golden
  with explicit t.Errorf so bad input no longer masquerades as a Go content
  failure.
- char_adapter.go: require per-page dims in charspy dumps (fail fast on
  missing/invalid) and remove the char-bbox RenderPageImage fallback that could
  degrade to a 1x1 placeholder (pageHeight ~1.33, boxes off-page).
- dedup_test.go: fix stale 'byte-identical' comment (grouping is trim-equal);
  add TestDedupSubstringOverlaps_PartialYOverlapKept pinning the boxInside
  Y-containment boundary.
- known_diffs.json: english-page-ocr-source-divergence note now reflects that
  the harness already clears replayed chars (engine.ClearChars).

Review: PR infiniflow#18490/infiniflow#18516 round 2 (items 1/2/5/6/7/8/10).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant