Skip to content

Fix template integration tests for typed parser DocItem output - #21141

Merged
yuzhichang merged 2 commits into
infiniflow:mainfrom
xugangqiang:fix-template-docitem-assertion
Oct 19, 2026
Merged

yuzhichang merged 2 commits into
infiniflow:mainfrom
xugangqiang:fix-template-docitem-assertion

Conversation

@xugangqiang

@xugangqiang xugangqiang commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two commits that make the internal/ingestion/pipeline integration tests pass against the current production contract. No production code changed — all fixes are test-only alignment.

1. Align parser json state to []parser.DocItem (PR #20998 regression)

PR #20998 changed the Parser component's json state from []map[string]any to []parser.DocItem but left the pipeline integration tests asserting the old map shape. Those tests are gated behind RequireTokenizerPool (skips when /usr/share/infinity/resource is absent), so CI skipped them and the break went unnoticed.

  • template_integration_test.go: three parserState["json"] assertions now type-assert []parser.DocItem and read text via DocItem.ToMap()["text"].
  • helpers_test.go: joinJSONItemTexts now accepts []parser.DocItem.
  • real_storage_integration_test.go: the same type assertion was missed in the earlier pass and is fixed here too.
  • component/parser.go: refreshed the stale []map[string]any output documentation left behind by refactor(parser): type ParseResult.JSON as []DocItem boundary adapter #20998.

2. Fix stale test expectations (pre-existing, unrelated to #20998)

  • Parser item count/text (TemplateManual_RealComponents): TextParser has emitted a single normalized json item since refactor(ingestion): migrate general parser and chunker contract #19611, but the test still asserted 6 items and per-part text. Aligned to the single-item contract.
  • Chunk text whitespace (TemplateGeneral_RealComponents, TemplateOne_RealComponents, TemplateGeneral_RealMySQLMinIO_OutputShape): the chunker preserves the blank line between the two seed paragraphs verbatim ("Alpha paragraph.\n\nBeta paragraph."); the tests expected it collapsed to a single newline. Updated the expectations (and corrected a now-inaccurate comment claiming whitespace collapsing).

How it was tested

  • Unit: build.sh --test ./internal/ingestion/pipeline/... ./internal/ingestion/component/... ./internal/parser/parser/... — all green.
  • Integration: build.sh --test-integration ./internal/ingestion/pipeline/ — fully green, 0 failures (all template tests pass after these fixes).

Note: the template integration tests still only run locally behind RequireTokenizerPool; CI skips them, so CI remains green for the same reason the original break slipped through.

Co-Authored-By: CodeBuddy [email protected]

PR infiniflow#20998 changed the Parser component's json state from
[]map[string]any to []parser.DocItem but did not update the pipeline
integration tests that still type-assert the old map shape. Those tests
are gated behind RequireTokenizerPool, so CI skipped them and the break
went unnoticed.

Update the three assertions and the joinJSONItemTexts helper to read the
typed DocItem via ToMap(), and refresh the stale []map[string]any output
documentation in ParserComponent.Outputs().

Co-Authored-By: CodeBuddy <[email protected]>
@xugangqiang xugangqiang added the ci Continue Integration label Oct 19, 2026
@coderabbitai

coderabbitai Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 024687a1-dd9f-4e28-a985-32bbb0308b34
📥 Commits

Reviewing files that changed from the base of the PR and between a10e043 and 696087c.

📒 Files selected for processing: 2
  • internal/ingestion/pipeline/real_storage_integration_test.go
  • internal/ingestion/pipeline/template_integration_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review.

📝 Walkthrough

The parser output documentation now describes json as []parser.DocItem. Ingestion pipeline tests use that type and access item text through ToMap(). Updated test expectations preserve paragraph breaks and expect the Manual template text in one item.

Changes: Parser output type alignment

Layer / File(s) Summary
Output contract and pipeline assertions
internal/ingestion/component/parser.go, internal/ingestion/pipeline/helpers_test.go, internal/ingestion/pipeline/real_storage_integration_test.go, internal/ingestion/pipeline/template_integration_test.go
Parser output documentation and pipeline tests use []parser.DocItem, with item text accessed through ToMap(). Updated expectations preserve blank lines between paragraphs. The Manual template test expects one item containing the full text.

Priority: ⬇️ Low

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

Change: Other

Suggested reviewers: jinhai-cn

Merge Risk: ⚪ Minimal · up to 69608

The changes align parser tests and output documentation with the typed parser contract. No concrete merge-blocking behavior change is established.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 7 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description includes the required Summary section and clearly explains the typed DocItem alignment, stale test expectations, affected files, and test results.
Title check Passed The title clearly and concisely describes the main change: updating template integration tests for typed parser DocItem output.
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.
  • Fix all pre-merge checks with AI
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

A rabbit checks each typed item,
And reads its text with ToMap().
Blank lines stay between the paragraphs,
One Manual item holds the full text.
The parser’s notes now match its type,
Then off the rabbit goes to hop.

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

… text)

Two classes of stale assertions in the pipeline integration tests, none of
which are caused by the parser DocItem refactor:

- Parser item count and text: TextParser has emitted a single normalized
  json item since infiniflow#19611, but TemplateManual_RealComponents still asserted 6
  items and per-part text. Align to the single-item contract.
- Chunk text whitespace: the chunker preserves the blank line between the
  two seed paragraphs verbatim ("Alpha paragraph.\n\nBeta paragraph."); the
  tests expected it collapsed to a single newline. Update the expectations
  for TemplateGeneral_RealComponents, TemplateOne_RealComponents and
  TemplateGeneral_RealMySQLMinIO_OutputShape.

Also align the parser json type assertion in real_storage_integration_test.go
to []parser.DocItem (same infiniflow#20998 regression missed by the earlier pass).

No production code changed; this is test-only alignment.

Co-Authored-By: CodeBuddy <[email protected]>

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. The []parser.DocItem type alignment is consistent across the output contract and integration tests, and the updated expectations match the typed parser output. No blocking findings.

@yuzhichang
yuzhichang merged commit 8f3dfba into infiniflow:main Oct 19, 2026
6 checks passed
@xugangqiang
xugangqiang deleted the fix-template-docitem-assertion branch October 28, 2026 02:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants