Skip to content

fix: Go ingestion migration batch 5 (Parser 1.1/1.7/2.11, Chunker 1.7/1.8/2.6/2.7, Tokenizer 6x fixes) - #17419

Merged
yuzhichang merged 5 commits into
infiniflow:mainfrom
xugangqiang:fix/batch-parser-chunker-5
Jul 28, 2026
Merged

yuzhichang merged 5 commits into
infiniflow:mainfrom
xugangqiang:fix/batch-parser-chunker-5

Conversation

@xugangqiang

@xugangqiang xugangqiang commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Continuation of the Python→Go ingestion pipeline migration (File → Parser → Chunker → Extractor → Tokenizer). Fixes cover Parser, Chunker, and Tokenizer gaps identified. Fix page number (0-indexed and 1-index mixed before fix; use 1-indexed after fix) and chunk order issues.

Parser

  • Slides TCADP (1.7): pptx_tcadp.go + TCADP branch in pptx_parser.go/ppt_parser.go — PowerPoint files now support parse_method="tcadp" via the TCADP cloud service, matching the spreadsheet-family TCADP pattern. PPT containers pass "PPT" as fileType (not hardcoded "PPTX").
  • Audio default output_format (2.11): defaultSetups() audio default changed from "text" to "json", aligning with Python parser.py:232 and AllowedOutputFormat["audio"]={"json"}.
  • PDF VLM enhancement (1.1): maybeDispatchPDFVisionEnhancement in pdf_vision_dispatch.go enriches image/table items with IMAGE2TEXT model descriptions after PDF parsing, mirroring Python enhance_media_sections_with_vision. Semaphore fix: acquire before goroutine start to prevent unbounded goroutine creation.
  • json family (2.3): reclassified as Keep Go — json_parser.go is a functional enhancement, not a parity gap.
  • page number: changed from "mixed use of 1-indexed & 0-indexed" to "1-indexed"

Chunker

  • BULLET_PATTERN fallback (1.7): 4th-level fallback in resolveTitleLevels (title.go) detects bullet/numbered-list patterns (Chinese legal, numbering, English) when outline + regex levels produce only bodyLevel. Guarded by allBodyLevel to never override existing structure.
  • Tag/One chunker fields (1.8): tag.go sets TopInt from source row index; one.go preserves Positions/PDFPositions from source items. TSV multi-line RowNum fix: tracks contentStart for correct row attribution.
  • Overlapped_percent normalization (2.6): NormalizeOverlappedPercent in schema/chunker.go mirrors Python common/float_utils.py:50-58 — accepts [0,1) fraction or [0,90] percent, normalizes to canonical [0,90].
  • Paragraph splitting (2.7): aligned to Python flow naive_merge — CRLF normalization, splitKeepingDelimiter preserves sentence delimiters, single-section merge with token-budget-governed chunking.
  • chunk order: sort by reading order

Tokenizer

  • Phantom chunk filtering (Omission 2): isPhantomChunk + filter loop in chunksFromTokenizerUpstream skips zero-value ChunkDocs.
  • Batch size env var (Omission 3): embeddingBatchSize() reads TOKENIZER_EMBEDDING_BATCH_SIZE, defaults to 16.
  • Summary empty check (Diff 5): TrimSpace(s) != "" → s != "", matching Python truthy check.
  • chunk_order_int all paths (Diff 8): set unconditionally before full_text/embedding branching.
  • Timeout default (Diff 10): 600s → 60s, matching Python @timeout(60).
  • Small maxTokens truncation (Diff 14): truncateForEmbedding returns "" when maxTokens <= 10, matching Python.

Code review fixes

  • Semaphore acquire moved before goroutine in pdf_vision_dispatch.go (concurrency control)
  • Context propagation in pptx_tcadp.go (cancellation support)
  • Test resolver leak fix in media_dispatch_test.go (defer restore)
  • Migration history comments removed per AGENTS.md

Test plan

bash build.sh --test ./internal/parser/parser/... ./internal/ingestion/component/...

Notes

  • Migration diff tracking: docs/migration_python_go_diff.md
  • Remaining gaps: Extractor component only (21 items)

@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jul 27, 2026
@coderabbitai

coderabbitai Bot commented Jul 27, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

The changes preserve chunk metadata, revise token merging, add media enrichment and JSON defaults, introduce TCADP presentation parsing, update tokenizer behavior, and align ingestion integration tests with context-aware APIs.

Changes

Chunking metadata and token merging

Layer / File(s) Summary
Chunk metadata and PDF preview cropping
internal/ingestion/component/chunker/{one,tag,token,title,group,hierarchy}.go, internal/ingestion/component/chunker/*test.go
Chunks preserve positions or source row indices, and title-related chunks can receive best-effort PDF previews.
Token merge and tag cleanup
internal/ingestion/component/chunker/token.go, internal/ingestion/component/chunker/token_test.go, internal/ingestion/component/chunker/token_tag_test.go
Token merging normalizes line endings, updates oversized-fragment handling, and removes parser position tags from emitted text.

Media dispatch and PDF vision

Layer / File(s) Summary
Media output defaults
internal/ingestion/component/{media_dispatch,parser}.go, internal/ingestion/component/media_dispatch_test.go
Audio defaults to JSON output, while video dispatch returns an unsupported error.
PDF vision post-processing
internal/ingestion/component/parser.go, internal/ingestion/component/pdf_vision_dispatch.go
Eligible PDF image and table items receive descriptions through bounded concurrent vision calls.

TCADP presentation parsing

Layer / File(s) Summary
TCADP page metadata
internal/parser/parser/pdf_parser_tcadp.go, internal/parser/parser/pdf_parser_tcadp_test.go
TCADP elements emit zero-based page positions when page metadata exists.
PPT and PPTX TCADP routing
internal/parser/parser/ppt_parser.go, internal/parser/parser/pptx_parser.go, internal/parser/parser/pptx_tcadp.go, internal/parser/parser/*_cgo_test.go
Presentation parsers accept setup configuration, route TCADP reconstruction, download artifacts, and convert them into structured results.

Tokenizer behavior and test API alignment

Layer / File(s) Summary
Tokenizer metadata and embedding behavior
internal/ingestion/component/tokenizer.go, internal/ingestion/component/tokenizer_unit_test.go, internal/ingestion/component/tokenizer_test.go
Embedding batching and timeout configuration, phantom filtering, ordering metadata, truncation, and summary handling are updated.
Context-aware integration tests
internal/ingestion/service/real_consumer_pipeline_test.go, internal/ingestion/task/real_consumer_test.go, internal/ingestion/pipeline/template_integration_test.go
Integration tests use context- and database-aware ingestion APIs and updated test embedder settings.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant ParserComponent
  participant PDFVisionEnhancement
  participant IMAGE2TEXT
  ParserComponent->>PDFVisionEnhancement: dispatch PDF JSON payload
  PDFVisionEnhancement->>IMAGE2TEXT: request image or table description
  IMAGE2TEXT-->>PDFVisionEnhancement: return description
  PDFVisionEnhancement-->>ParserComponent: append description to item text
Loading
sequenceDiagram
  participant PPTParser
  participant PPTXParser
  participant TCADP
  participant ArtifactConverter
  PPTParser->>PPTXParser: configure and delegate parsing
  PPTXParser->>TCADP: submit presentation for reconstruction
  TCADP-->>PPTXParser: return artifact URL
  PPTXParser->>TCADP: download artifact ZIP
  PPTXParser->>ArtifactConverter: convert ZIP to structured items
  ArtifactConverter-->>PPTXParser: return parse result
Loading

Possibly related PRs

Suggested labels: 🐞 bug

Suggested reviewers: yingfeng, yuzhichang, jinhai-cn

Poem

I hop through chunks where coordinates gleam,
JSON carries audio downstream in a stream.
Visions adorn tables and images bright,
Slides cross TCADP through pages of light.
Squeak—the parser paths align just right!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.64% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
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.
Title check ✅ Passed The title is related to the main migration changes and clearly scopes parser, chunker, and tokenizer fixes.
Description check ✅ Passed The PR description includes the required Summary and provides clear scope, background, and test-plan context.

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.

@xugangqiang xugangqiang added the ci Continue Integration label Jul 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (3)
internal/ingestion/component/chunker/one_test.go (1)

102-118: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover both position fields with exact assertions.

The implementation now propagates both Positions and PDFPositions, but this test only checks that positions is non-nil. Supply pdf_positions and assert both output values match the input so an empty or incorrectly transformed payload cannot pass.

As per coding guidelines, “Preserve valid behavior with focused tests.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/one_test.go` around lines 102 - 118,
Update TestOneChunker_PreservesPositions to include a pdf_positions input
alongside positions, then assert both output fields exactly match their
respective input values rather than only checking positions is non-nil. Preserve
the existing single-chunk validation and use the test’s established chunk output
structure.

Source: Coding guidelines

internal/ingestion/component/chunker/tag_test.go (1)

149-161: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Assert the actual row indices.

Both checks accept any single-element top_int, including [0] for both chunks. Assert float64(0) and float64(1) respectively, as the CSV test already does, to protect the TSV extractor’s row-index contract.

As per coding guidelines, “Preserve valid behavior with focused tests.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/tag_test.go` around lines 149 - 161,
Update the assertions in the TSV checks around the top_int validation to verify
the single element’s value, not only its length: require float64(0) for
chunks[0] and float64(1) for chunks[1]. Preserve the existing missing-field and
unexpected-type checks while adding focused failures for incorrect row indices.

Source: Coding guidelines

internal/parser/parser/ppt_parser_cgo_test.go (1)

71-91: 🎯 Functional Correctness | 🔵 Trivial | 🏗️ Heavy lift

Test the actual TCADP request routing.

These tests only inspect fields. Add a local TCADP test server and assert the submitted payload uses file_type: "PPT" and file_type: "PPTX" respectively, then return a ZIP artifact to cover the full route.

Also applies to: 95-108

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/parser/parser/ppt_parser_cgo_test.go` around lines 71 - 91, The test
currently verifies only parser configuration, not TCADP request routing. Extend
the relevant PPT parser tests, including the additional case around the other
TCADP test, with a local TCADP server that captures submitted payloads, assert
PPT and PPTX requests send the corresponding file_type values, and have the
server return a ZIP artifact so the complete request and response path is
exercised.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/ingestion/component/chunker/one.go`:
- Around line 148-149: Remove migration-history annotations and rewrite comments
to describe only current behavior: in
internal/ingestion/component/chunker/one.go lines 148-149 delete diff
annotations, and lines 169-173 retain only the composite-geometry rationale; in
internal/ingestion/component/chunker/tag.go lines 128 and 137-139 remove
annotations and document RowNum’s current contract without Python references; in
internal/ingestion/component/chunker/token.go lines 306-312, 347-362, and
432-453 describe delimiter retention, normalization, single-payload behavior,
and split/merge rationale using only present behavior; update the corresponding
expectations in internal/ingestion/component/chunker/tag_test.go lines 137-139
and 165-169 and internal/ingestion/component/chunker/token_test.go lines
493-497, 531-533, 542-546, 567-571, 593-599, and 626-629 to remove review,
migration, Python, and prior-design wording while retaining concise descriptions
of the tested behavior.

In `@internal/ingestion/component/chunker/tag.go`:
- Line 175: Track the first physical line where the accumulated content becomes
non-empty, and use that contentStartLine when constructing tagPair instead of
the terminating tag row. Update both TSV emission at
internal/ingestion/component/chunker/tag.go:175-175 and CSV emission at
internal/ingestion/component/chunker/tag.go:222-222; preserve the start line
across malformed or multi-line CSV records, and add regression coverage for TSV
and CSV preamble rows.

In `@internal/ingestion/component/media_dispatch_test.go`:
- Around line 320-324: Update the test setup around defaultSetups so it
explicitly clears the audio output format before exercising the fallback path,
rather than relying on the existing default "json" value. Restore the
package-level resolveTenantModelByType resolver after the test completes to
prevent state leaking into other tests.

In `@internal/ingestion/component/parser.go`:
- Around line 494-499: Remove Python-parity and migration-history wording from
the comments at internal/ingestion/component/parser.go:494-499,
internal/ingestion/component/media_dispatch_test.go:314-316, and
internal/ingestion/component/pdf_vision_dispatch.go:554-559. Keep each comment
focused on the current Go behavior: PDF JSON vision enrichment and the expected
default behavior, without Python implementation, diff, or compatibility
references.

In `@internal/ingestion/component/pdf_vision_dispatch.go`:
- Around line 596-604: Update the target-processing loop around the goroutine
launched for each target so the semaphore token is acquired before starting the
goroutine, bounding both goroutine creation and model calls. Remove the
in-goroutine acquisition and ensure each completed worker releases its token
while preserving the existing WaitGroup synchronization and description
handling.

In `@internal/parser/parser/pdf_parser_tcadp_test.go`:
- Around line 119-121: Strengthen the “nested array of elements keeps each page”
test by asserting the parsed item count and validating both nested items’
complete position tuples, including the expected page values for pages 1 and 7.
Apply the same assertion coverage to the related cases around the test’s other
nested-array expectations, rather than checking only items[0].

In `@internal/parser/parser/pdf_parser_tcadp.go`:
- Around line 181-185: Update the default branch in the PDF parser so ordinary
text emitted by emit retains the layout value "text" rather than "layout". Keep
the existing empty-text return behavior unchanged.
- Around line 150-156: Remove migration-history, Python, spreadsheet-comparison,
and compatibility wording from comments across the listed parser and test sites.
Update each comment around the TCADP/PPT/PPTX parser symbols to describe only
current position formatting, delegation, setup forwarding, parse/output
behavior, TCADP operations, and the routing contracts asserted by the tests; all
listed sites require comment-only updates.

In `@internal/parser/parser/pptx_tcadp.go`:
- Around line 20-22: Propagate the caller’s context through the TCADP parsing
flow: update parsePresentationWithTCADP in internal/parser/parser/pptx_tcadp.go
(lines 20-22) to accept context.Context, pass ctx from the caller in
internal/parser/parser/pptx_parser.go (lines 97-103), and use it for
PostJSONRequest (pptx_tcadp.go lines 48-49) and the artifact download request
(lines 70-71) instead of context.Background().

---

Nitpick comments:
In `@internal/ingestion/component/chunker/one_test.go`:
- Around line 102-118: Update TestOneChunker_PreservesPositions to include a
pdf_positions input alongside positions, then assert both output fields exactly
match their respective input values rather than only checking positions is
non-nil. Preserve the existing single-chunk validation and use the test’s
established chunk output structure.

In `@internal/ingestion/component/chunker/tag_test.go`:
- Around line 149-161: Update the assertions in the TSV checks around the
top_int validation to verify the single element’s value, not only its length:
require float64(0) for chunks[0] and float64(1) for chunks[1]. Preserve the
existing missing-field and unexpected-type checks while adding focused failures
for incorrect row indices.

In `@internal/parser/parser/ppt_parser_cgo_test.go`:
- Around line 71-91: The test currently verifies only parser configuration, not
TCADP request routing. Extend the relevant PPT parser tests, including the
additional case around the other TCADP test, with a local TCADP server that
captures submitted payloads, assert PPT and PPTX requests send the corresponding
file_type values, and have the server return a ZIP artifact so the complete
request and response path is exercised.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: ede3e03a-d8b1-41e1-88cd-69d89746b7a4

📥 Commits

Reviewing files that changed from the base of the PR and between 3065a29 and 8dcfa25.

📒 Files selected for processing (16)
  • internal/ingestion/component/chunker/one.go
  • internal/ingestion/component/chunker/one_test.go
  • internal/ingestion/component/chunker/tag.go
  • internal/ingestion/component/chunker/tag_test.go
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/chunker/token_test.go
  • internal/ingestion/component/media_dispatch.go
  • internal/ingestion/component/media_dispatch_test.go
  • internal/ingestion/component/parser.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/parser/parser/pdf_parser_tcadp.go
  • internal/parser/parser/pdf_parser_tcadp_test.go
  • internal/parser/parser/ppt_parser.go
  • internal/parser/parser/ppt_parser_cgo_test.go
  • internal/parser/parser/pptx_parser.go
  • internal/parser/parser/pptx_tcadp.go

Comment on lines +148 to +149
Positions: it.Positions, // diff Chunker-1.8
PDFPositions: it.PDFPositions, // diff Chunker-1.8

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Remove migration-history commentary from current Go code and tests.

Keep only concise explanations of the present behavior; remove references to Python parity, old Go behavior, diff batches, and prior review findings.

  • internal/ingestion/component/chunker/one.go#L148-L149: remove the diff annotations.
  • internal/ingestion/component/chunker/one.go#L169-L173: retain only the current rationale for omitting composite geometry.
  • internal/ingestion/component/chunker/tag.go#L128-L128: remove the diff annotation.
  • internal/ingestion/component/chunker/tag.go#L137-L139: document RowNum’s current contract without the Python reference.
  • internal/ingestion/component/chunker/token.go#L306-L312: describe delimiter retention without Python-port history.
  • internal/ingestion/component/chunker/token.go#L347-L362: describe normalization and single-payload behavior without prior-design history.
  • internal/ingestion/component/chunker/token.go#L432-L453: retain only the current split/merge rationale.
  • internal/ingestion/component/chunker/tag_test.go#L137-L139: describe the expected top_int behavior without Python references.
  • internal/ingestion/component/chunker/tag_test.go#L165-L169: remove the prior-review reference.
  • internal/ingestion/component/chunker/token_test.go#L493-L497: describe CRLF expectations without migration context.
  • internal/ingestion/component/chunker/token_test.go#L531-L533: remove prior-design commentary.
  • internal/ingestion/component/chunker/token_test.go#L542-L546: describe blank-line expectations without historical implementation details.
  • internal/ingestion/component/chunker/token_test.go#L567-L571: describe delimiter expectations without Python-port history.
  • internal/ingestion/component/chunker/token_test.go#L593-L599: remove review-history and migration wording.
  • internal/ingestion/component/chunker/token_test.go#L626-L629: describe boundary coverage without review-history references.

As per coding guidelines, “Do not add new compatibility wording in comments or documentation.”

📍 Affects 5 files
  • internal/ingestion/component/chunker/one.go#L148-L149 (this comment)
  • internal/ingestion/component/chunker/one.go#L169-L173
  • internal/ingestion/component/chunker/tag.go#L128-L128
  • internal/ingestion/component/chunker/tag.go#L137-L139
  • internal/ingestion/component/chunker/token.go#L306-L312
  • internal/ingestion/component/chunker/token.go#L347-L362
  • internal/ingestion/component/chunker/token.go#L432-L453
  • internal/ingestion/component/chunker/tag_test.go#L137-L139
  • internal/ingestion/component/chunker/tag_test.go#L165-L169
  • internal/ingestion/component/chunker/token_test.go#L493-L497
  • internal/ingestion/component/chunker/token_test.go#L531-L533
  • internal/ingestion/component/chunker/token_test.go#L542-L546
  • internal/ingestion/component/chunker/token_test.go#L567-L571
  • internal/ingestion/component/chunker/token_test.go#L593-L599
  • internal/ingestion/component/chunker/token_test.go#L626-L629
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/one.go` around lines 148 - 149, Remove
migration-history annotations and rewrite comments to describe only current
behavior: in internal/ingestion/component/chunker/one.go lines 148-149 delete
diff annotations, and lines 169-173 retain only the composite-geometry
rationale; in internal/ingestion/component/chunker/tag.go lines 128 and 137-139
remove annotations and document RowNum’s current contract without Python
references; in internal/ingestion/component/chunker/token.go lines 306-312,
347-362, and 432-453 describe delimiter retention, normalization, single-payload
behavior, and split/merge rationale using only present behavior; update the
corresponding expectations in internal/ingestion/component/chunker/tag_test.go
lines 137-139 and 165-169 and internal/ingestion/component/chunker/token_test.go
lines 493-497, 531-533, 542-546, 567-571, 593-599, and 626-629 to remove review,
migration, Python, and prior-design wording while retaining concise descriptions
of the tested behavior.

Source: Coding guidelines

Comment thread internal/ingestion/component/parser.go Outdated
Comment on lines +494 to +499
// PDF vision figure enhancement: enrich parsed PDF JSON
// items with vision-model descriptions of embedded
// images/tables (doc_type_kwd "image"/"table" with non-empty
// image field). Mirrors Python's enhance_media_sections_with_vision
// in parser.py:_pdf (diff Parser-1.1).
dispatched, _, _ = maybeDispatchPDFVisionEnhancement(ctx, fileTypeExt, dispatched, inputs)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove Python-parity and migration-history wording from new Go comments.

Keep comments focused on current Go behavior; the repository guideline prohibits new compatibility wording.

  • internal/ingestion/component/parser.go#L494-L499: describe PDF JSON vision enrichment without Python or diff references.
  • internal/ingestion/component/media_dispatch_test.go#L314-L316: describe the expected default behavior without Python implementation references.
  • internal/ingestion/component/pdf_vision_dispatch.go#L554-L559: document the enhancement’s Go behavior without Python or diff references.
📍 Affects 3 files
  • internal/ingestion/component/parser.go#L494-L499 (this comment)
  • internal/ingestion/component/media_dispatch_test.go#L314-L316
  • internal/ingestion/component/pdf_vision_dispatch.go#L554-L559
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/parser.go` around lines 494 - 499, Remove
Python-parity and migration-history wording from the comments at
internal/ingestion/component/parser.go:494-499,
internal/ingestion/component/media_dispatch_test.go:314-316, and
internal/ingestion/component/pdf_vision_dispatch.go:554-559. Keep each comment
focused on the current Go behavior: PDF JSON vision enrichment and the expected
default behavior, without Python implementation, diff, or compatibility
references.

Source: Coding guidelines

Comment on lines +150 to +156
// 0-indexed 5-tuple (page-1). The ingestion pipeline
// (processChunkPositions -> AddPositions,
// internal/ingestion/task/position.go) converts this to
// page_num_int=[page], top_int=[0] and
// position_int=[[page,0,0,0,0]], mirroring Python
// presentation.py:148-149. Fixes migration diff Parser-2.13
// (presentation TCADP items dropped slide page location).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Remove migration-history wording from the new Go comments.

  • internal/parser/parser/pdf_parser_tcadp.go#L150-L156: describe the current position format only.
  • internal/parser/parser/pdf_parser_tcadp_test.go#L89-L96: describe the tested behavior without migration/Python references.
  • internal/parser/parser/ppt_parser.go#L23-L24: document current delegation behavior only.
  • internal/parser/parser/ppt_parser.go#L37-L39: document current setup forwarding only.
  • internal/parser/parser/ppt_parser.go#L44-L48: document current parse delegation only.
  • internal/parser/parser/ppt_parser_cgo_test.go#L66-L70: state the asserted routing contract only.
  • internal/parser/parser/ppt_parser_cgo_test.go#L93-L94: state the asserted PPTX routing contract only.
  • internal/parser/parser/pptx_parser.go#L37-L37: remove the migration reference.
  • internal/parser/parser/pptx_parser.go#L54-L55: document setup parsing without historical comparison.
  • internal/parser/parser/pptx_parser.go#L83-L85: document current output behavior only.
  • internal/parser/parser/pptx_tcadp.go#L16-L19: document the TCADP operation without spreadsheet/migration comparison.

As per coding guidelines, “Do not add new compatibility wording in comments or documentation,” and Go comments must remain aligned with the current runtime path.

📍 Affects 6 files
  • internal/parser/parser/pdf_parser_tcadp.go#L150-L156 (this comment)
  • internal/parser/parser/pdf_parser_tcadp_test.go#L89-L96
  • internal/parser/parser/ppt_parser.go#L23-L24
  • internal/parser/parser/ppt_parser.go#L37-L39
  • internal/parser/parser/ppt_parser.go#L44-L48
  • internal/parser/parser/ppt_parser_cgo_test.go#L66-L70
  • internal/parser/parser/ppt_parser_cgo_test.go#L93-L94
  • internal/parser/parser/pptx_parser.go#L37-L37
  • internal/parser/parser/pptx_parser.go#L54-L55
  • internal/parser/parser/pptx_parser.go#L83-L85
  • internal/parser/parser/pptx_tcadp.go#L16-L19
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/parser/parser/pdf_parser_tcadp.go` around lines 150 - 156, Remove
migration-history, Python, spreadsheet-comparison, and compatibility wording
from comments across the listed parser and test sites. Update each comment
around the TCADP/PPT/PPTX parser symbols to describe only current position
formatting, delegation, setup forwarding, parse/output behavior, TCADP
operations, and the routing contracts asserted by the tests; all listed sites
require comment-only updates.

Source: Coding guidelines

Comment thread internal/parser/parser/pptx_tcadp.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
internal/ingestion/component/chunker/token.go (1)

293-308: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-history commentary from Go comments.

Keep these comments focused on the current delimiter and merge semantics; remove Python source paths, prior implementation notes, Chunker/review IDs, and update the adjacent delimiter description so it no longer mentions the removed . fallback.

  • internal/ingestion/component/chunker/token.go#L293-L308: document only the active delimiter set and merge behavior.
  • internal/ingestion/component/chunker/token.go#L323-L337: describe LF normalization and whole-payload processing without porting history.
  • internal/ingestion/component/chunker/token.go#L408-L426: describe delimiter-dropping and threshold routing without review references.
  • internal/ingestion/component/chunker/token_test.go#L566-L573: reduce the test comment to its asserted delimiter-removal behavior.
  • internal/ingestion/component/chunker/token_test.go#L595-L607: reduce the test comment to its asserted blank-line behavior.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/token.go` around lines 293 - 308, Remove
migration-history and review-specific commentary from the documented sites: in
internal/ingestion/component/chunker/token.go lines 293-308, 323-337, and
408-426, retain only the active delimiter, merge, LF-normalization,
whole-payload, delimiter-dropping, and threshold-routing behavior; in
internal/ingestion/component/chunker/token_test.go lines 566-573 and 595-607,
reduce comments to the asserted delimiter-removal and blank-line behavior.
Update the delimiter description to omit the removed “. ” fallback, and remove
Python paths, prior implementation notes, and Chunker/review IDs without
changing code behavior.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/ingestion/component/chunker/token.go`:
- Around line 293-308: Remove migration-history and review-specific commentary
from the documented sites: in internal/ingestion/component/chunker/token.go
lines 293-308, 323-337, and 408-426, retain only the active delimiter, merge,
LF-normalization, whole-payload, delimiter-dropping, and threshold-routing
behavior; in internal/ingestion/component/chunker/token_test.go lines 566-573
and 595-607, reduce comments to the asserted delimiter-removal and blank-line
behavior. Update the delimiter description to omit the removed “. ” fallback,
and remove Python paths, prior implementation notes, and Chunker/review IDs
without changing code behavior.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 16835a7a-c192-4d71-940b-17e25fe35368

📥 Commits

Reviewing files that changed from the base of the PR and between 8dcfa25 and 78872c1.

📒 Files selected for processing (7)
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/chunker/token_test.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/ingestion/component/tokenizer_test.go
  • internal/ingestion/service/real_consumer_pipeline_test.go
  • internal/ingestion/task/real_consumer_test.go
  • internal/parser/parser/pdf_parser_tcadp.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/parser/parser/pdf_parser_tcadp.go
  • internal/ingestion/component/pdf_vision_dispatch.go

xugangqiang added a commit to xugangqiang/ragflow that referenced this pull request Jul 27, 2026
PR infiniflow#17419 deleted TestTokenChunkerParam_UpdatePreservesOverlappedPercent
and the huge-value clamp cases in TestNormalizeOverlappedPercent.
The underlying behavior is still correct (Update only writes
overlapped_percent when the key is present; clampOverlappedPercent
clamps >90 to 90 before the int conversion, avoiding Go's
implementation-defined float->int for values like 1e300), so this
only restores the regression-safety net those tests provided.

- Re-add TestTokenChunkerParam_UpdatePreservesOverlappedPercent
- Re-add huge-value clamp cases (1e300 / -1e300 / MaxFloat64)

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/ingestion/component/chunker/token_test.go`:
- Around line 409-412: Revise the comments around the out-of-range normalization
tests in the token test cases to describe only the current contract: clamp huge
values to 90 before converting to an integer, and document the required
partial-update behavior where applicable. Remove Python references,
review-finding numbers, and migration or compatibility history.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 2499769d-eae4-4b69-972e-e2b9041038e1

📥 Commits

Reviewing files that changed from the base of the PR and between 78872c1 and a8f9472.

📒 Files selected for processing (1)
  • internal/ingestion/component/chunker/token_test.go

@xugangqiang xugangqiang changed the title fix(parser/chunker): Go ingestion migration batch 5 (slides audio tag/one positions, CRLF, TCADP page) WIP Fix: Go ingestion migration batch 5 (slides audio tag/one positions, CRLF, TCADP page) Jul 27, 2026
@xugangqiang
xugangqiang force-pushed the fix/batch-parser-chunker-5 branch from a8f9472 to 9e3395d Compare July 27, 2026 10:00
@dosubot dosubot Bot added size:XL This PR changes 500-999 lines, ignoring generated files. and removed size:L This PR changes 100-499 lines, ignoring generated files. labels Jul 27, 2026
@xugangqiang xugangqiang changed the title WIP Fix: Go ingestion migration batch 5 (slides audio tag/one positions, CRLF, TCADP page) fix: Go ingestion migration batch 5 (Parser 1.1/1.7/2.11, Chunker 1.7/1.8/2.6/2.7, Tokenizer 6x fixes) Jul 27, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 9

🧹 Nitpick comments (2)
internal/ingestion/component/tokenizer.go (1)

120-123: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-history references from runtime documentation.

Describe the current invariant directly; Diff, Omission, Python-path, and migration-parity references will become stale.

  • internal/ingestion/component/tokenizer.go#L120-L123: document the environment variable, validation, and default only.
  • internal/ingestion/component/tokenizer.go#L357-L359: document the all-path chunk-order invariant only.
  • internal/ingestion/component/tokenizer.go#L510-L513: document the reserved-token behavior only.
  • internal/ingestion/component/tokenizer.go#L578-L581: document the local phantom-filtering rule only.
  • internal/ingestion/component/tokenizer.go#L592-L594: document the local definition of usable chunk content only.
  • internal/ingestion/component/tokenizer_unit_test.go#L353-L354: state the tested phantom-chunk behavior only.
  • internal/ingestion/component/tokenizer_unit_test.go#L373-L375: state the small-token truncation expectation only.
  • internal/ingestion/component/tokenizer_unit_test.go#L390-L392: state the environment configuration behavior only.
  • internal/ingestion/component/tokenizer_unit_test.go#L409-L412: state the embedding-only ordering expectation only.
  • internal/ingestion/component/tokenizer_unit_test.go#L449-L454: state the upstream filtering expectation only.

As per coding guidelines, “Keep Go package comments and doc comments aligned with the current runtime path rather than migration history.”

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/tokenizer.go` around lines 120 - 123, Remove
migration-history, Diff/Omission, Python-path, and migration-parity references
from the documented comments at
internal/ingestion/component/tokenizer.go:120-123, 357-359, 510-513, 578-581,
and 592-594, describing only the current environment/default validation, chunk
ordering, reserved-token, phantom-filtering, and usable-content invariants
respectively. Update
internal/ingestion/component/tokenizer_unit_test.go:353-354, 373-375, 390-392,
409-412, and 449-454 likewise to state only each test’s current phantom
behavior, truncation expectation, environment configuration, embedding ordering,
and upstream filtering behavior.

Source: Coding guidelines

internal/ingestion/component/chunker/qa.go (1)

140-141: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Finish or remove the broken migration-comment edits.

  • internal/ingestion/component/chunker/qa.go#L140-L141: replace the orphaned fragment with a complete metadata-restoration comment.
  • internal/ingestion/component/chunker/token_batch1_test.go#L70-L72: remove the duplicate period.
  • internal/ingestion/component/chunker/token_batch1_test.go#L142-L142: replace the incomplete fragment with a current test description.
  • internal/ingestion/component/chunker/qa_batch2_test.go#L44-L44: describe the tested default behavior without migration wording.
  • internal/ingestion/component/chunker/qa_test.go#L215-L216: remove the duplicate period.
  • internal/ingestion/component/schema/chunker.go#L188-L193: restore the missing separator in the OverlappedPercent sentence.

As per coding guidelines, remove “stale documentation” and keep Go documentation aligned with the current runtime path rather than migration history.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/qa.go` around lines 140 - 141, Clean up
the migration-comment edits across all listed sites: in
internal/ingestion/component/chunker/qa.go lines 140-141, replace the orphaned
fragment with a complete comment describing metadata restoration; in
internal/ingestion/component/chunker/token_batch1_test.go lines 70-72 remove the
duplicate period and line 142 replace the incomplete fragment with the current
test description; in internal/ingestion/component/chunker/qa_batch2_test.go line
44 describe the tested default behavior without migration wording; in
internal/ingestion/component/chunker/qa_test.go lines 215-216 remove the
duplicate period; and in internal/ingestion/component/schema/chunker.go lines
188-193 restore the missing separator in the OverlappedPercent documentation
sentence.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/ingestion/component/chunker/tag_test.go`:
- Around line 149-162: Update the top_int assertions in the chunk verification
to validate the contained row index, not only that each value is a one-element
[]any. Ensure chunk 0 contains 0 and chunk 1 contains 1, while retaining the
existing missing-key and unexpected-type checks.

In `@internal/ingestion/component/chunker/title.go`:
- Around line 767-769: Update the dispatch cases in the component’s invoke flow
to pass the resolved name value into both invokeHierarchy and invokeGroup
instead of the original c.param map, preserving the upstream re-decode/cropping
behavior for globals-only runs.

In `@internal/ingestion/component/chunker/token.go`:
- Around line 382-385: Update the comment immediately above sentenceDelimiter to
accurately describe only the delimiters supported by the regex, removing the
claim that English ". " is included while retaining the documented Python
delimiters and ASCII punctuation details.

In `@internal/ingestion/component/media_dispatch.go`:
- Around line 376-379: Remove the unused videoMIME helper and its associated
future-video-parsing reference comment from the media dispatch implementation,
leaving maybeDispatchVideo and the existing unsupported-video behavior
unchanged.
- Around line 65-79: Update the video-parsing comment in maybeDispatchVideo to
describe only current behavior, removing references to the previously shipped
path, migration history, and docs/migration_python_go_diff.md. Preserve the
current provider-specific implementation guidance and explicit unsupported
error. In defaultSetups, simplify the "video" entry by removing unused
output_format and prompt values, retaining only the suffix list.

In `@internal/ingestion/component/tokenizer_unit_test.go`:
- Line 26: Update TestEmbeddingBatchSizeEnvVar to capture the existing
TOKENIZER_EMBEDDING_BATCH_SIZE value before exercising each case, then restore
that value during cleanup instead of unconditionally removing it. Ensure the
test’s default assertion is isolated from the caller’s process environment and
cleanup runs only after all cases complete.

In `@internal/ingestion/component/tokenizer.go`:
- Line 716: Update the Summary branch in the chunk tokenization logic to trim
ck.Summary before checking whether it is empty, so whitespace-only summaries
fall back to ck.Text. Preserve the existing behavior for summaries containing
non-whitespace content.
- Around line 592-596: The isPhantomChunk predicate currently discards
summary-only chunks and retains whitespace-only content. Update isPhantomChunk
to trim every indexable content field, including Text, Image, ContentWithWeight,
Summary, Questions, and Keywords, and return true only when all trimmed values
are empty; preserve chunks containing any meaningful content.

In `@internal/parser/parser/pptx_tcadp.go`:
- Around line 78-86: Update the download flow in the TCADP parser around
NewDriverHTTPClient().Do so it validates downloadResp.StatusCode before reading
or parsing the ZIP, returning a ParseResult error for non-2xx responses.
Preserve the existing response-body cleanup and successful ZIP-reading path for
2xx responses.

---

Nitpick comments:
In `@internal/ingestion/component/chunker/qa.go`:
- Around line 140-141: Clean up the migration-comment edits across all listed
sites: in internal/ingestion/component/chunker/qa.go lines 140-141, replace the
orphaned fragment with a complete comment describing metadata restoration; in
internal/ingestion/component/chunker/token_batch1_test.go lines 70-72 remove the
duplicate period and line 142 replace the incomplete fragment with the current
test description; in internal/ingestion/component/chunker/qa_batch2_test.go line
44 describe the tested default behavior without migration wording; in
internal/ingestion/component/chunker/qa_test.go lines 215-216 remove the
duplicate period; and in internal/ingestion/component/schema/chunker.go lines
188-193 restore the missing separator in the OverlappedPercent documentation
sentence.

In `@internal/ingestion/component/tokenizer.go`:
- Around line 120-123: Remove migration-history, Diff/Omission, Python-path, and
migration-parity references from the documented comments at
internal/ingestion/component/tokenizer.go:120-123, 357-359, 510-513, 578-581,
and 592-594, describing only the current environment/default validation, chunk
ordering, reserved-token, phantom-filtering, and usable-content invariants
respectively. Update
internal/ingestion/component/tokenizer_unit_test.go:353-354, 373-375, 390-392,
409-412, and 449-454 likewise to state only each test’s current phantom
behavior, truncation expectation, environment configuration, embedding ordering,
and upstream filtering behavior.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f2e7b0f7-dcf6-4c25-9cda-303a98546279

📥 Commits

Reviewing files that changed from the base of the PR and between a8f9472 and 9e3395d.

📒 Files selected for processing (32)
  • internal/ingestion/component/chunker/crop_title_test.go
  • internal/ingestion/component/chunker/group.go
  • internal/ingestion/component/chunker/hierarchy.go
  • internal/ingestion/component/chunker/one.go
  • internal/ingestion/component/chunker/one_test.go
  • internal/ingestion/component/chunker/qa.go
  • internal/ingestion/component/chunker/qa_batch2_test.go
  • internal/ingestion/component/chunker/qa_test.go
  • internal/ingestion/component/chunker/tag.go
  • internal/ingestion/component/chunker/tag_test.go
  • internal/ingestion/component/chunker/title.go
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/chunker/token_batch1_test.go
  • internal/ingestion/component/chunker/token_tag_test.go
  • internal/ingestion/component/chunker/token_test.go
  • internal/ingestion/component/media_dispatch.go
  • internal/ingestion/component/media_dispatch_test.go
  • internal/ingestion/component/parser.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/ingestion/component/schema/chunker.go
  • internal/ingestion/component/tokenizer.go
  • internal/ingestion/component/tokenizer_test.go
  • internal/ingestion/component/tokenizer_unit_test.go
  • internal/ingestion/pipeline/template_integration_test.go
  • internal/ingestion/service/real_consumer_pipeline_test.go
  • internal/ingestion/task/real_consumer_test.go
  • internal/parser/parser/pdf_parser_tcadp.go
  • internal/parser/parser/pdf_parser_tcadp_test.go
  • internal/parser/parser/ppt_parser.go
  • internal/parser/parser/ppt_parser_cgo_test.go
  • internal/parser/parser/pptx_parser.go
  • internal/parser/parser/pptx_tcadp.go
🚧 Files skipped from review as they are similar to previous changes (12)
  • internal/ingestion/component/chunker/one_test.go
  • internal/ingestion/component/media_dispatch_test.go
  • internal/ingestion/component/chunker/one.go
  • internal/parser/parser/ppt_parser_cgo_test.go
  • internal/parser/parser/ppt_parser.go
  • internal/ingestion/task/real_consumer_test.go
  • internal/parser/parser/pdf_parser_tcadp_test.go
  • internal/parser/parser/pdf_parser_tcadp.go
  • internal/parser/parser/pptx_parser.go
  • internal/ingestion/component/chunker/tag.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/ingestion/component/chunker/token_test.go

Comment on lines +767 to +769
return invokeHierarchy(ctx, db, inputs, &c.param)
case "group":
return invokeGroup(ctx, inputs, &c.param)
return invokeGroup(ctx, db, inputs, &c.param)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Forward the resolved name into the dispatch helpers.

Unlike the direct Group/Hierarchy components, these paths pass the original map. Globals-only runs can therefore miss the newly added upstream re-decode/cropping path.

Proposed fix
 case "hierarchy":
-	return invokeHierarchy(ctx, db, inputs, &c.param)
+	return invokeHierarchy(ctx, db, withName(inputs, name), &c.param)
 case "group":
-	return invokeGroup(ctx, db, inputs, &c.param)
+	return invokeGroup(ctx, db, withName(inputs, name), &c.param)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
return invokeHierarchy(ctx, db, inputs, &c.param)
case "group":
return invokeGroup(ctx, inputs, &c.param)
return invokeGroup(ctx, db, inputs, &c.param)
return invokeHierarchy(ctx, db, withName(inputs, name), &c.param)
case "group":
return invokeGroup(ctx, db, withName(inputs, name), &c.param)
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/title.go` around lines 767 - 769, Update
the dispatch cases in the component’s invoke flow to pass the resolved name
value into both invokeHierarchy and invokeGroup instead of the original c.param
map, preserving the upstream re-decode/cropping behavior for globals-only runs.

Comment on lines +65 to +79
if _, ok := setups["video"]; !ok {
return parserDispatchResult{}, false, nil
}
tenantID := getStringOr(inputs, "tenant_id", "")
if tenantID == "" {
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video requires tenant_id")
}

// Resolve the tenant's IMAGE2TEXT model.
driver, modelName, apiConfig, _, err := resolveTenantModelByType(tenantID, entity.ModelTypeImage2Text)
if err != nil {
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video image2text model: %w", err)
}

videoPrompt, _ := setup["prompt"].(string)
videoB64 := base64.StdEncoding.EncodeToString(binary)

// Build a multimodal message with the video payload.
// Python uses cv_mdl.async_chat(video_bytes=blob, ...);
// Go ChatWithMessages is synchronous and uses a data URI.
mimeType := videoMIME(filename)
dataURI := "data:" + mimeType + ";base64," + videoB64
messages := []modelModule.Message{{
Role: "user",
Content: []interface{}{
map[string]any{"type": "text", "text": videoPrompt},
map[string]any{"type": "video_url", "video_url": map[string]any{"url": dataURI}},
},
}}
vision := true
resp, err := driver.ChatWithMessages(ctx, modelName, messages, apiConfig, &modelModule.ChatConfig{Vision: &vision}, nil)
if err != nil {
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video describe: %w", err)
}
txt := ""
if resp != nil && resp.Answer != nil {
txt = strings.TrimSpace(*resp.Answer)
}

outputFormat, _ := setup["output_format"].(string)
if outputFormat == "" {
outputFormat = "text"
}
return parserDispatchResult{
OutputFormat: outputFormat,
DocType: "video",
Text: txt,
}, true, nil
// Video parsing is intentionally not implemented yet: the underlying
// video-analysis capability is pending. The previously-shipped path sent a
// video_url data URI, but no model driver honors it — OpenAI-compatible
// drivers only accept image_url (the block is ignored), and Gemini's
// googleMessageParts only accepts text/image_url and silently drops
// video_url. Returning an explicit error is safer than silently producing
// a description from the prompt text alone. The real implementation must
// be provider-specific (OpenAI-compatible: frame extraction -> image_url;
// Gemini: raw-bytes inline_data; Qwen: file://) — see
// docs/migration_python_go_diff.md 2.7.
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video parsing is not yet supported; underlying video analysis capability is pending")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

Drop migration-history wording from the new comment.

The rationale for deferring video parsing is useful, but referencing docs/migration_python_go_diff.md 2.7 and "the previously-shipped path" ties this Go doc comment to migration history rather than describing current behavior.

Separately, since maybeDispatchVideo no longer reads output_format/prompt from the video setup (it only checks key presence), the "video" entry in defaultSetups() (internal/ingestion/component/parser.go lines 316-320: output_format: "text", prompt: "") is now dead configuration — worth pruning to just the suffix list.

♻️ Proposed comment cleanup
-	// Video parsing is intentionally not implemented yet: the underlying
-	// video-analysis capability is pending. The previously-shipped path sent a
-	// video_url data URI, but no model driver honors it — OpenAI-compatible
-	// drivers only accept image_url (the block is ignored), and Gemini's
-	// googleMessageParts only accepts text/image_url and silently drops
-	// video_url. Returning an explicit error is safer than silently producing
-	// a description from the prompt text alone. The real implementation must
-	// be provider-specific (OpenAI-compatible: frame extraction -> image_url;
-	// Gemini: raw-bytes inline_data; Qwen: file://) — see
-	// docs/migration_python_go_diff.md 2.7.
+	// Video parsing is intentionally not implemented yet: no model driver
+	// accepts a video_url payload today (OpenAI-compatible drivers ignore
+	// it; Gemini's message builder silently drops it). Returning an
+	// explicit error is safer than silently producing a description from
+	// prompt text alone. A real implementation must be provider-specific
+	// (OpenAI-compatible: frame extraction -> image_url; Gemini: raw-bytes
+	// inline_data; Qwen: file://).

As per coding guidelines, "Keep Go package comments and doc comments aligned with the current runtime path rather than migration history."

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if _, ok := setups["video"]; !ok {
return parserDispatchResult{}, false, nil
}
tenantID := getStringOr(inputs, "tenant_id", "")
if tenantID == "" {
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video requires tenant_id")
}
// Resolve the tenant's IMAGE2TEXT model.
driver, modelName, apiConfig, _, err := resolveTenantModelByType(tenantID, entity.ModelTypeImage2Text)
if err != nil {
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video image2text model: %w", err)
}
videoPrompt, _ := setup["prompt"].(string)
videoB64 := base64.StdEncoding.EncodeToString(binary)
// Build a multimodal message with the video payload.
// Python uses cv_mdl.async_chat(video_bytes=blob, ...);
// Go ChatWithMessages is synchronous and uses a data URI.
mimeType := videoMIME(filename)
dataURI := "data:" + mimeType + ";base64," + videoB64
messages := []modelModule.Message{{
Role: "user",
Content: []interface{}{
map[string]any{"type": "text", "text": videoPrompt},
map[string]any{"type": "video_url", "video_url": map[string]any{"url": dataURI}},
},
}}
vision := true
resp, err := driver.ChatWithMessages(ctx, modelName, messages, apiConfig, &modelModule.ChatConfig{Vision: &vision}, nil)
if err != nil {
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video describe: %w", err)
}
txt := ""
if resp != nil && resp.Answer != nil {
txt = strings.TrimSpace(*resp.Answer)
}
outputFormat, _ := setup["output_format"].(string)
if outputFormat == "" {
outputFormat = "text"
}
return parserDispatchResult{
OutputFormat: outputFormat,
DocType: "video",
Text: txt,
}, true, nil
// Video parsing is intentionally not implemented yet: the underlying
// video-analysis capability is pending. The previously-shipped path sent a
// video_url data URI, but no model driver honors it — OpenAI-compatible
// drivers only accept image_url (the block is ignored), and Gemini's
// googleMessageParts only accepts text/image_url and silently drops
// video_url. Returning an explicit error is safer than silently producing
// a description from the prompt text alone. The real implementation must
// be provider-specific (OpenAI-compatible: frame extraction -> image_url;
// Gemini: raw-bytes inline_data; Qwen: file://) — see
// docs/migration_python_go_diff.md 2.7.
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video parsing is not yet supported; underlying video analysis capability is pending")
if _, ok := setups["video"]; !ok {
return parserDispatchResult{}, false, nil
}
// Video parsing is intentionally not implemented yet: no model driver
// accepts a video_url payload today (OpenAI-compatible drivers ignore
// it; Gemini's message builder silently drops it). Returning an
// explicit error is safer than silently producing a description from
// prompt text alone. A real implementation must be provider-specific
// (OpenAI-compatible: frame extraction -> image_url; Gemini: raw-bytes
// inline_data; Qwen: file://).
return parserDispatchResult{}, true,
fmt.Errorf("Parser: video parsing is not yet supported; underlying video analysis capability is pending")
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/media_dispatch.go` around lines 65 - 79, Update
the video-parsing comment in maybeDispatchVideo to describe only current
behavior, removing references to the previously shipped path, migration history,
and docs/migration_python_go_diff.md. Preserve the current provider-specific
implementation guidance and explicit unsupported error. In defaultSetups,
simplify the "video" entry by removing unused output_format and prompt values,
retaining only the suffix list.

Source: Coding guidelines

Comment on lines +376 to +379
// for constructing base64 data URIs. Retained as a reference for the
// future real video-parsing implementation (provider-specific frame
// extraction / inline_data / file://); not currently used because
// maybeDispatchVideo returns an explicit unsupported error.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Confirm videoMIME has no remaining callers before deleting.
rg -n 'videoMIME' --type=go

Repository: infiniflow/ragflow

Length of output: 156


🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "Files named media_dispatch.go:"
fd -a 'media_dispatch\.go$' . || true

echo
echo "Occurrences of videoMIME in tracked files:"
git grep -n 'videoMIME' || true

echo
echo "Occurrences of maybeDispatchVideo in tracked Go files:"
git grep -n 'maybeDispatchVideo' -- '*.go' || true

echo
echo "Relevant lines in internal/ingestion/component/media_dispatch.go:"
sed -n '350,395p' internal/ingestion/component/media_dispatch.go

Repository: infiniflow/ragflow

Length of output: 2260


Remove the unused videoMIME helper.

videoMIME has no Callers, and this is explicitly a placeholder reference to future video parsing. Delete the function and its comment to avoid retaining dead migration/dual-track code.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/media_dispatch.go` around lines 376 - 379,
Remove the unused videoMIME helper and its associated future-video-parsing
reference comment from the media dispatch implementation, leaving
maybeDispatchVideo and the existing unsupported-video behavior unchanged.

Source: Coding guidelines

Comment on lines +592 to +596
// isPhantomChunk returns true when a ChunkDoc has no usable content
// for downstream tokenization or embedding. Mirrors Python's
// none-chunk filtering (diff Tokenizer Omission-2).
func isPhantomChunk(ck schema.ChunkDoc) bool {
return ck.Text == "" && ck.Image == "" && ck.ContentWithWeight == ""

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Preserve meaningful chunks and remove whitespace-only ones.

This runs before tokenizeChunks, which supports Summary, Questions, and Keywords; summary-only chunks are currently discarded. Conversely, whitespace-only Text/Image/ContentWithWeight values survive as phantom chunks. Base this predicate on trimmed values of all indexable content fields.

Proposed fix
 func isPhantomChunk(ck schema.ChunkDoc) bool {
-	return ck.Text == "" && ck.Image == "" && ck.ContentWithWeight == ""
+	return strings.TrimSpace(ck.Text) == "" &&
+		strings.TrimSpace(ck.Image) == "" &&
+		strings.TrimSpace(ck.ContentWithWeight) == "" &&
+		strings.TrimSpace(ck.Summary) == "" &&
+		strings.TrimSpace(ck.Questions) == "" &&
+		strings.TrimSpace(ck.Keywords) == ""
 }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// isPhantomChunk returns true when a ChunkDoc has no usable content
// for downstream tokenization or embedding. Mirrors Python's
// none-chunk filtering (diff Tokenizer Omission-2).
func isPhantomChunk(ck schema.ChunkDoc) bool {
return ck.Text == "" && ck.Image == "" && ck.ContentWithWeight == ""
// isPhantomChunk returns true when a ChunkDoc has no usable content
// for downstream tokenization or embedding. Mirrors Python's
// none-chunk filtering (diff Tokenizer Omission-2).
func isPhantomChunk(ck schema.ChunkDoc) bool {
return strings.TrimSpace(ck.Text) == "" &&
strings.TrimSpace(ck.Image) == "" &&
strings.TrimSpace(ck.ContentWithWeight) == "" &&
strings.TrimSpace(ck.Summary) == "" &&
strings.TrimSpace(ck.Questions) == "" &&
strings.TrimSpace(ck.Keywords) == ""
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/tokenizer.go` around lines 592 - 596, The
isPhantomChunk predicate currently discards summary-only chunks and retains
whitespace-only content. Update isPhantomChunk to trim every indexable content
field, including Text, Image, ContentWithWeight, Summary, Questions, and
Keywords, and return true only when all trimmed values are empty; preserve
chunks containing any meaningful content.

Comment thread internal/parser/parser/pptx_tcadp.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (2)
internal/ingestion/component/chunker/token_tag_test.go (1)

22-25: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-history terminology from test comments.

“Residual B” is not meaningful runtime behavior and will become stale; describe only the parser-tag cleanup contract.

Proposed cleanup
-// TestTokenChunker_TextPath_StripsParserTags pins residual B: the
-// TokenChunker text path must not leak parser position tags (@@...##)
+// TestTokenChunker_TextPath_StripsParserTags verifies that the
+// TokenChunker text path does not leak parser position tags (@@...##)
...
-// TestTokenChunker_JSONPath_StripsParserTags pins residual B for the
-// structured (output_format == "json") path.
+// TestTokenChunker_JSONPath_StripsParserTags verifies the same behavior
+// for the structured (output_format == "json") path.

As per coding guidelines, “Remove dead tests, commented-out code, stale documentation, and 'move later' notes instead of preserving them.”

Also applies to: 55-56

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/token_tag_test.go` around lines 22 - 25,
Update the comments for TestTokenChunker_TextPath_StripsParserTags, including
the additional referenced comment range, to remove migration-history terminology
such as “Residual B.” Keep only the runtime contract that parser position tags
must not appear in final chunk text.

Source: Coding guidelines

internal/ingestion/component/chunker/crop_title_test.go (1)

24-32: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-era and line-number references from the test contract.

residual A, the TokenChunker comparison, and pdfcrop_cgo.go:151 describe migration/history rather than the observable behavior under test. Keep the comment focused on inputs and expected output. As per coding guidelines, remove stale documentation and keep Go comments aligned with the current runtime path rather than migration history.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/ingestion/component/chunker/crop_title_test.go` around lines 24 -
32, Update the comment above TestCropTitleChunks_CropsPositionedChunk to remove
migration/history references, including “residual A,” the TokenChunker
comparison, and the pdfcrop_cgo.go line reference. Keep only the observable
contract: chunk inputs may contain doc_type_kwd and positions without ck_type,
positioned text chunks receive a rendered preview, positionless chunks remain
unchanged, and derived ck_type is absent from the returned shape.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@internal/parser/parser/pptx_tcadp.go`:
- Around line 1-14: Restore parser test-package compilation by removing the
unused context imports from office_parsers_nocgo_test.go and
pdf_parser_nocgo_test.go, unless those tests are updated to use context. Leave
the production imports in pptx_tcadp.go unchanged.

---

Nitpick comments:
In `@internal/ingestion/component/chunker/crop_title_test.go`:
- Around line 24-32: Update the comment above
TestCropTitleChunks_CropsPositionedChunk to remove migration/history references,
including “residual A,” the TokenChunker comparison, and the pdfcrop_cgo.go line
reference. Keep only the observable contract: chunk inputs may contain
doc_type_kwd and positions without ck_type, positioned text chunks receive a
rendered preview, positionless chunks remain unchanged, and derived ck_type is
absent from the returned shape.

In `@internal/ingestion/component/chunker/token_tag_test.go`:
- Around line 22-25: Update the comments for
TestTokenChunker_TextPath_StripsParserTags, including the additional referenced
comment range, to remove migration-history terminology such as “Residual B.”
Keep only the runtime contract that parser position tags must not appear in
final chunk text.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: e96d1972-7d2a-40dd-a25f-b92f3588b44b

📥 Commits

Reviewing files that changed from the base of the PR and between 9e3395d and 5e19315.

📒 Files selected for processing (32)
  • internal/ingestion/component/chunker/crop_title_test.go
  • internal/ingestion/component/chunker/group.go
  • internal/ingestion/component/chunker/hierarchy.go
  • internal/ingestion/component/chunker/one.go
  • internal/ingestion/component/chunker/one_test.go
  • internal/ingestion/component/chunker/qa.go
  • internal/ingestion/component/chunker/qa_batch2_test.go
  • internal/ingestion/component/chunker/qa_test.go
  • internal/ingestion/component/chunker/tag.go
  • internal/ingestion/component/chunker/tag_test.go
  • internal/ingestion/component/chunker/title.go
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/chunker/token_batch1_test.go
  • internal/ingestion/component/chunker/token_tag_test.go
  • internal/ingestion/component/chunker/token_test.go
  • internal/ingestion/component/media_dispatch.go
  • internal/ingestion/component/media_dispatch_test.go
  • internal/ingestion/component/parser.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/ingestion/component/schema/chunker.go
  • internal/ingestion/component/tokenizer.go
  • internal/ingestion/component/tokenizer_test.go
  • internal/ingestion/component/tokenizer_unit_test.go
  • internal/ingestion/pipeline/template_integration_test.go
  • internal/ingestion/service/real_consumer_pipeline_test.go
  • internal/ingestion/task/real_consumer_test.go
  • internal/parser/parser/pdf_parser_tcadp.go
  • internal/parser/parser/pdf_parser_tcadp_test.go
  • internal/parser/parser/ppt_parser.go
  • internal/parser/parser/ppt_parser_cgo_test.go
  • internal/parser/parser/pptx_parser.go
  • internal/parser/parser/pptx_tcadp.go
🚧 Files skipped from review as they are similar to previous changes (29)
  • internal/ingestion/component/chunker/one_test.go
  • internal/ingestion/component/chunker/qa_test.go
  • internal/ingestion/component/chunker/qa_batch2_test.go
  • internal/ingestion/component/schema/chunker.go
  • internal/parser/parser/pdf_parser_tcadp.go
  • internal/ingestion/service/real_consumer_pipeline_test.go
  • internal/parser/parser/ppt_parser_cgo_test.go
  • internal/ingestion/component/chunker/qa.go
  • internal/ingestion/component/chunker/token_batch1_test.go
  • internal/ingestion/pipeline/template_integration_test.go
  • internal/ingestion/task/real_consumer_test.go
  • internal/ingestion/component/chunker/one.go
  • internal/ingestion/component/media_dispatch.go
  • internal/ingestion/component/chunker/hierarchy.go
  • internal/parser/parser/ppt_parser.go
  • internal/ingestion/component/tokenizer_unit_test.go
  • internal/ingestion/component/chunker/tag_test.go
  • internal/parser/parser/pptx_parser.go
  • internal/ingestion/component/parser.go
  • internal/ingestion/component/chunker/title.go
  • internal/ingestion/component/chunker/group.go
  • internal/ingestion/component/media_dispatch_test.go
  • internal/ingestion/component/chunker/tag.go
  • internal/parser/parser/pdf_parser_tcadp_test.go
  • internal/ingestion/component/chunker/token.go
  • internal/ingestion/component/tokenizer_test.go
  • internal/ingestion/component/tokenizer.go
  • internal/ingestion/component/pdf_vision_dispatch.go
  • internal/ingestion/component/chunker/token_test.go

Comment thread internal/parser/parser/pptx_tcadp.go Resolved
@xugangqiang
xugangqiang force-pushed the fix/batch-parser-chunker-5 branch from 10cecb4 to 4e18a75 Compare July 27, 2026 12:10
@xugangqiang

Copy link
Copy Markdown
Contributor Author

@yingfeng @yuzhichang @JinHai-CN pls help to review

// (10 min) to match the canvas-level component timeout default.
// Invalid / non-positive values fall back to the default.
// Reads COMPONENT_EXEC_TIMEOUT_TOKENIZER env var (seconds); defaults to 60s
// to match Python's @timeout(60). Invalid / non-positive values fall back

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.

I think Python's component timeout is a bad design.

@yuzhichang

Copy link
Copy Markdown
Member

LGTM

@yuzhichang
yuzhichang merged commit 9b0719f into infiniflow:main Jul 28, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:XL This PR changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants