Skip to content

fix(ingestion): align laws DSL with Python — heading fallback, colon-title, short-line filter, remove_toc, and image extension mapping - #17200

Merged
yuzhichang merged 3 commits into
infiniflow:mainfrom
xugangqiang:feat/dsl-laws
Jul 22, 2026

Conversation

@xugangqiang

@xugangqiang xugangqiang commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR aligns the Go ingestion pipeline's Laws DSL template with the Python implementation by fixing heading-detection gaps, adds image-extension support, refactors the Extractor component's LLM resolution, hardens heading detection for CJK text, and makes the Extractor accept the Python DSL prompt key names (sys_prompt/prompts) alongside the Go names.

Changes

1. Picture file-type detection (internal/utility/file.go)

Adds explicit mapping for common image extensions (png, jpg, jpeg, gif, bmp, tiff, tif, webp, svg, ico, avif, heic, apng) → FileTypeVISUAL, with regression tests.

2. Laws DSL heading-detection alignment (internal/ingestion/component/chunker/)

Four fixes to resolveTitleLevels:

Fix What changed Why
DOCX ck_type fallback ckType field on lineRecord, propagated from ChunkDoc.CKType in recordsFromStructured. When ck_type=="heading", assign fallbackLevel. office_oxide extracts DOCX heading metadata, but the info was lost before reaching the heading detector. Word headings whose text doesn't match any regex (e.g. "Introduction") were treated as body.
make_colon_as_title promotion isColonTitle(): promotes lines ending with :/: that have sentence-ending punctuation before the colon and ≥32 runes between them. Mirrors Python's make_colon_as_title in rag/nlp/__init__.py. Triple guard prevents false positives.
Short/numeric line filter Lines with ≤1 rune or purely numeric are pinned to body level. Mirrors Python tree_merge's filter of sections where len(...) <= 1 or re.match(r"[0-9]+$", ...).
PDF remove_toc "remove_toc": true added to the PDF parser setup in ingestion_pipeline_laws.json. The Go PDF parser already supports TOC removal; the Book template already enables it.

3. Extractor llm_id resolution (internal/ingestion/component/extractor.go)

Refactored to handle both bare tenant_model UUIDs and composite model@provider strings via the shared resolveModelConfig (dispatch_model.go):

  • resolveExtractorChatConfig — UUID path calls resolveModelConfigByID directly (one DB hit); composite path goes through resolveModelConfig. Added isBareTenantModelID pre-check for clear errors when a UUID doesn't exist.
  • resolveExtractorChatTarget — propagates resolution errors instead of silently returning empty driver.
  • Chat() — removed driver = "dummy" fallback. Missing driver is now an explicit error.
  • Removed dead code: splitExtractorLLID, findExtractorSoleActiveInstance.

4. InjectExtractorLLMID — fallback when no user config (internal/common/parser_config.go)

Injects the tenant's global default LLM into extractor components only when their llm_id is empty. Preserves user-selected UUID or model@provider values.

Priority: user-configured llm_id > tenant global default > error (no silent dummy fallback).

5. ResponseHeaderTimeout increase (internal/entity/models/base_model.go)

ResponseHeaderTimeout 60s → 120s in NewDriverHTTPClient. Reasoning models with large extraction prompts can take longer than 60s to produce the first response token.

6. CJK rune-aware heading detection (internal/ingestion/component/chunker/title.go)

Two byte-vs-rune bugs that only manifest on CJK text:

Fix What changed Why
isColonTitle byte offset body[lastPunct+1:] → body[lastPunct+runeLen:] via utf8.DecodeRuneInString strings.LastIndexAny returns a byte index; +1 skips only 1 byte, corrupting multi-byte CJK punctuation (e.g. 。 = 3 bytes) and inflating the rune count past the 32-rune threshold → false-positive heading promotion.
Short-line filter byte count len(text) <= 1 → utf8.RuneCountInString(text) <= 1 Go len is UTF-8 bytes; a single CJK char (3 bytes) passed the filter, but Python's len returns 1 → mismatch.

7. extractor_tag.go — log error when llm fails

When resolveExtractorChatTarget returned an error, runAutoTags will log error.

8. Python DSL prompt-key compatibility (internal/ingestion/component/extractor.go)

The Resume DSL template uses Python-side key names (sys_prompt, prompts). NewExtractorComponent now accepts them as fallbacks alongside the Go names:

  • system_prompt (Go) ← sys_prompt (Python) as fallback
  • prompt (Go string) ← prompts (Python array [{"role","content"}], takes [0].content) as fallback

Mirrors the alias pattern already in internal/agent/component/llm.go. resolveInputs accepts per-call sys_prompt override too.

Remaining gaps vs Python

Gap Scope Impact
TOC removal for TXT/MD/HTML Python's remove_contents_table works on all text formats; Go's remove_toc is PDF-only. Low — plain-text documents rarely contain structured TOCs.
Regex pattern details Minor differences in quantifiers, missing H5/H6 markdown patterns, missing 4-level numbering pattern. Low — Go's variants are stricter; DOCX headings are covered by ck_type fallback.

Testing

  • TestHierarchyTitleChunker_CKTypeHeadingFallback — DOCX ck_type heading promotion
  • TestHierarchyTitleChunker_ColonTitlePromotion / _ColonTitleShortLine_Negative — colon-title promotion + guard
  • TestIsColonTitle_CJKEdgeCase / TestIsColonTitle_ASCII_NoRegression — CJK byte-offset fix + ASCII regression
  • TestHierarchyTitleChunker_ColonTitlePromotion_CJK_EdgeCase — CJK colon edge case through full pipeline
  • TestHierarchyTitleChunker_ShortSingleCJKLineFilter — single CJK char filtered to body
  • TestHierarchyTitleChunker_ShortNumericLineFilter — purely numeric lines filtered
  • TestGetFileType_ImageExtensions / _ExistingFormats_NoRegression — image extension mapping
  • TestInjectExtractorLLMID_SkipWhenUUID / _SkipWhenComposite / _InjectWhenEmpty — llm_id injection guard
  • TestIsBareTenantModelID — UUID detection
  • TestResolveExtractorChatTarget_AtSplitFallback / _NoDriver — @ split fallback without DB
  • TestNewExtractorComponent_SysPromptAlias / _PromptsArray / _PromptsArray_PromptWins / _SystemPromptWinsOverSysPrompt — Python key compatibility
  • TestBuildDOCXJSONSections_List / _TextBox / _MixedWithList — DOCX list/text_box parsing
  • Full ingestion test suite passes (chunker, pipeline, task, service, component packages)

@dosubot dosubot Bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Jul 21, 2026
@coderabbitai

coderabbitai Bot commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The PR updates hierarchy heading detection, extractor model resolution, DOCX section parsing, image file classification, parser configuration, HTTP/LLM timeouts, and ingestion template defaults with corresponding tests.

Changes

Chunker heading resolution

Layer / File(s) Summary
Heading metadata and title-level resolution
internal/ingestion/component/chunker/group.go, internal/ingestion/component/chunker/title.go
Structured records propagate CKType; title resolution filters numeric-only lines and promotes typed headings or qualifying colon-ended titles.
Hierarchy resolution coverage
internal/ingestion/component/chunker/hierarchy_test.go
Tests cover colon-title promotion, short-line rejection, numeric-line filtering, CJK thresholds, and CKType heading fallback.

Extractor target resolution

Layer / File(s) Summary
Chat target and invocation flow
internal/ingestion/component/extractor.go, internal/ingestion/component/extractor_tag.go, internal/entity/models/base_model.go
Extractor target and tenant configuration errors propagate, unresolved drivers return errors, prompt aliases are supported, auto-tagging handles failures, and timeout values increase.
Extractor resolution coverage
internal/ingestion/component/extractor_test.go
Tests cover prompt precedence, bare tenant model IDs, and fallback parsing for provider-qualified and driverless identifiers.

DOCX section parsing

Layer / File(s) Summary
DOCX IR decoding and section construction
internal/parser/parser/docx_parser.go
Raw DOCX content is decoded into runs or blocks; list and text-box elements now produce text sections, with related figure, paragraph, and table handling updated.
DOCX parsing coverage
internal/parser/parser/docx_parser_test.go
Tests cover list items, text boxes, mixed ordering, and raw JSON table content.

Ingestion configuration updates

Layer / File(s) Summary
Pipeline template and golden defaults
internal/ingestion/pipeline/template/ingestion_pipeline_laws.json, internal/ingestion/pipeline/template/ingestion_pipeline_resume.json, internal/ingestion/task/pipeline_executor_defaults_test.go
The laws PDF parser removes TOCs, resume title chunker root-heading settings are removed, and laws parameter defaults are refreshed.
Extractor model-ID preservation
internal/common/parser_config.go, internal/common/parser_config_test.go
Existing non-empty extractor LLM IDs are preserved, while missing or empty IDs receive defaults with focused tests.

Visual file classification

Layer / File(s) Summary
Image extension classification
internal/utility/file.go, internal/utility/file_test.go
Additional image extensions map to FileTypeVISUAL, with regression and fallback cases covered.

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

Sequence Diagram(s)

sequenceDiagram
  participant ExtractorComponent
  participant resolveExtractorChatTarget
  participant resolveExtractorChatConfig
  participant ChatInvoker
  ExtractorComponent->>resolveExtractorChatTarget: resolve llm_id
  resolveExtractorChatTarget->>resolveExtractorChatConfig: resolve tenant model configuration
  resolveExtractorChatConfig-->>resolveExtractorChatTarget: driver, model, credentials or error
  resolveExtractorChatTarget-->>ExtractorComponent: chat target or error
  ExtractorComponent->>ChatInvoker: generate extraction request
  ChatInvoker-->>ExtractorComponent: response or invocation error
Loading

Possibly related PRs

  • infiniflow/ragflow#17216: Overlapping chunker changes for short or numeric line filtering and CKType-based heading promotion.

Suggested reviewers: qinling0210, rayhanest

Poem

A rabbit hops through headings bright,
DOCX lists split clean and light.
Models resolve or errors show,
Image types join the visual flow.
Tests guard each change just right.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 43.75% 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 clearly describes the main change: aligning Laws ingestion behavior with Python and related file-type handling.
Description check ✅ Passed The description includes the required Summary and gives clear context, with additional detail that does not conflict with the template.

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 21, 2026
@xugangqiang
xugangqiang requested a review from qinling0210 July 21, 2026 14:29
@xugangqiang

Copy link
Copy Markdown
Contributor Author

@yuzhichang Let's discuss

@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: 2

🧹 Nitpick comments (2)
internal/utility/file.go (1)

117-122: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Consolidate cases for FileTypeVISUAL.

Multiple case statements return the exact same FileTypeVISUAL. To improve readability and consistency with existing cases (like the ones returning FileTypeTXT), you can combine these into a single case.

💡 Proposed refactor
-	case "png", "jpg", "jpeg", "gif", "bmp":
-		return FileTypeVISUAL
-	case "tiff", "tif", "webp", "svg", "ico":
-		return FileTypeVISUAL
-	case "avif", "heic", "apng":
+	case "png", "jpg", "jpeg", "gif", "bmp",
+		"tiff", "tif", "webp", "svg", "ico",
+		"avif", "heic", "apng":
		return FileTypeVISUAL
🤖 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/utility/file.go` around lines 117 - 122, Consolidate the three
visual-extension branches in the file-type switch into one case listing all
extensions that return FileTypeVISUAL, preserving the existing mappings and
behavior.
internal/ingestion/component/chunker/hierarchy_test.go (1)

230-377: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Tests pass but don't exercise CJK punctuation paths.

All new cases use ASCII text/digits, so they won't catch the byte-vs-rune bugs flagged in title.go's isColonTitle (Lines 275-296) and short-line filter (Lines 311-317), even though the punctuation set explicitly includes CJK marks (。?!;). Consider adding a colon-title case using CJK sentence punctuation to pin the correct behavior once those are fixed.

🤖 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/hierarchy_test.go` around lines 230 -
377, The tests only cover ASCII punctuation and digits, leaving CJK rune
handling in isColonTitle and the short-line filter untested. Extend the relevant
hierarchy title chunker tests with CJK text, including a colon-title line
containing 。、?! or ; before the colon, and verify it is promoted while
preserving the existing short-line behavior.
🤖 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/title.go`:
- Around line 275-296: Fix isColonTitle so the substring after lastPunct starts
after the full punctuation rune rather than advancing by one byte. Use
rune-aware indexing or the matched punctuation’s UTF-8 width when deriving
between, preserving the existing whitespace trimming and 32-rune threshold
behavior.
- Around line 311-317: Update the short-line condition in the record-processing
logic around beforeAt to compare Unicode character count rather than UTF-8 byte
length, matching Python’s len behavior. Preserve the numericOnly check and
existing bodyLevel assignment flow.

---

Nitpick comments:
In `@internal/ingestion/component/chunker/hierarchy_test.go`:
- Around line 230-377: The tests only cover ASCII punctuation and digits,
leaving CJK rune handling in isColonTitle and the short-line filter untested.
Extend the relevant hierarchy title chunker tests with CJK text, including a
colon-title line containing 。、?! or ; before the colon, and verify it is
promoted while preserving the existing short-line behavior.

In `@internal/utility/file.go`:
- Around line 117-122: Consolidate the three visual-extension branches in the
file-type switch into one case listing all extensions that return
FileTypeVISUAL, preserving the existing mappings and 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

Run ID: 69c2c75c-4046-40ff-ba82-c889ee86f261

📥 Commits

Reviewing files that changed from the base of the PR and between 6a85d1c and 71668dc.

📒 Files selected for processing (7)
  • internal/ingestion/component/chunker/group.go
  • internal/ingestion/component/chunker/hierarchy_test.go
  • internal/ingestion/component/chunker/title.go
  • internal/ingestion/pipeline/template/ingestion_pipeline_laws.json
  • internal/ingestion/task/pipeline_executor_defaults_test.go
  • internal/utility/file.go
  • internal/utility/file_test.go

@dosubot dosubot Bot added size:L This PR changes 100-499 lines, ignoring generated files. and removed size:M This PR changes 30-99 lines, ignoring generated files. labels Jul 22, 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: 4

🤖 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/common/parser_config_test.go`:
- Around line 45-51: Update TestInjectExtractorLLMID_NoExtractor to inspect the
nested Parser:X configuration after calling InjectExtractorLLMID, asserting that
llm_id remains an empty string and the function returns false. Keep the existing
assertion that Parser:X remains present.

In `@internal/ingestion/component/extractor_tag.go`:
- Around line 174-178: Update the resolveExtractorChatTarget error branch in
runAutoTags to return in.chunks instead of an empty slice, while preserving the
existing nil error and warning log so failed target resolution skips tagging
without discarding content.

In `@internal/ingestion/component/extractor.go`:
- Around line 351-357: Update the chat logging around wrapper.Generate to stop
including req.Messages content at Info or Error level. Log only safe metadata
such as message count and total content size, while preserving the existing
error context and generation behavior.

In `@internal/parser/parser/docx_parser.go`:
- Around line 368-379: Update the list handling around extractTextFromListItem
and docxIRListItem.Nested so nested list items are recursively decoded and
emitted as sections, preserving their order and text instead of processing only
direct el.Items. Collapse any transitional “move later” path while implementing
the recursive traversal, and add a regression fixture covering nested DOCX
bullets.
🪄 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

Run ID: dc466f84-b850-4c9e-b6dd-8df68f4eb3d2

📥 Commits

Reviewing files that changed from the base of the PR and between 71668dc and cc667c8.

📒 Files selected for processing (10)
  • internal/common/parser_config.go
  • internal/common/parser_config_test.go
  • internal/entity/models/base_model.go
  • internal/ingestion/component/extractor.go
  • internal/ingestion/component/extractor_tag.go
  • internal/ingestion/component/extractor_test.go
  • internal/ingestion/pipeline/template/ingestion_pipeline_resume.json
  • internal/ingestion/task/pipeline_executor_defaults_test.go
  • internal/parser/parser/docx_parser.go
  • internal/parser/parser/docx_parser_test.go

Comment on lines +45 to +51
func TestInjectExtractorLLMID_NoExtractor(t *testing.T) {
pc := map[string]interface{}{
"Parser:X": map[string]interface{}{"llm_id": ""},
}
result := ExtractPipelineDefaults(dsl)
raw := result["TokenChunker:abc"].(map[string]interface{})
delims, _ := raw["delimiters"].([]interface{})
if len(delims) != 3 {
t.Fatalf("expected 3 delimiters, got %v", delims)
InjectExtractorLLMID(pc, "default@provider")
if _, ok := pc["Parser:X"]; !ok {
t.Fatal("expected Parser:X still present")

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

Assert that the parser model ID is unchanged.

The current assertion passes even if Parser:X.llm_id is overwritten. Verify it remains "" and that the function returns false.

Proposed test fix
-	InjectExtractorLLMID(pc, "default@provider")
-	if _, ok := pc["Parser:X"]; !ok {
-		t.Fatal("expected Parser:X still present")
+	if InjectExtractorLLMID(pc, "default@provider") {
+		t.Fatal("expected no update without an Extractor component")
+	}
+	id := pc["Parser:X"].(map[string]interface{})["llm_id"].(string)
+	if id != "" {
+		t.Fatalf("expected Parser:X llm_id unchanged, got %q", id)
 	}
📝 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
func TestInjectExtractorLLMID_NoExtractor(t *testing.T) {
pc := map[string]interface{}{
"Parser:X": map[string]interface{}{"llm_id": ""},
}
result := ExtractPipelineDefaults(dsl)
raw := result["TokenChunker:abc"].(map[string]interface{})
delims, _ := raw["delimiters"].([]interface{})
if len(delims) != 3 {
t.Fatalf("expected 3 delimiters, got %v", delims)
InjectExtractorLLMID(pc, "default@provider")
if _, ok := pc["Parser:X"]; !ok {
t.Fatal("expected Parser:X still present")
func TestInjectExtractorLLMID_NoExtractor(t *testing.T) {
pc := map[string]interface{}{
"Parser:X": map[string]interface{}{"llm_id": ""},
}
if InjectExtractorLLMID(pc, "default@provider") {
t.Fatal("expected no update without an Extractor component")
}
id := pc["Parser:X"].(map[string]interface{})["llm_id"].(string)
if id != "" {
t.Fatalf("expected Parser:X llm_id unchanged, got %q", id)
}
}
🤖 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/common/parser_config_test.go` around lines 45 - 51, Update
TestInjectExtractorLLMID_NoExtractor to inspect the nested Parser:X
configuration after calling InjectExtractorLLMID, asserting that llm_id remains
an empty string and the function returns false. Keep the existing assertion that
Parser:X remains present.

Comment on lines +174 to +178
driver, model, apiKey, baseURL, err := resolveExtractorChatTarget(ctx, in.llmID)
if err != nil {
common.Warn("extractor tag: resolve model failed", zap.Error(err))
return []map[string]any{}, nil
}

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.

🗄️ Data Integrity & Integration | 🔴 Critical | ⚡ Quick win

Returning an empty slice on resolve failure drops all chunks.

Every other exit path in runAutoTags returns in.chunks (Lines 145, 154, 217), but the error branch returns []map[string]any{}, nil. When target resolution fails, LLM tagging should simply be skipped — instead this discards every chunk and the pipeline proceeds with zero data. Return the original chunks so untagged content is preserved.

🐛 Suggested fix
 		driver, model, apiKey, baseURL, err := resolveExtractorChatTarget(ctx, in.llmID)
 		if err != nil {
 			common.Warn("extractor tag: resolve model failed", zap.Error(err))
-			return []map[string]any{}, nil
+			return in.chunks, nil
 		}
📝 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
driver, model, apiKey, baseURL, err := resolveExtractorChatTarget(ctx, in.llmID)
if err != nil {
common.Warn("extractor tag: resolve model failed", zap.Error(err))
return []map[string]any{}, nil
}
driver, model, apiKey, baseURL, err := resolveExtractorChatTarget(ctx, in.llmID)
if err != nil {
common.Warn("extractor tag: resolve model failed", zap.Error(err))
return in.chunks, nil
}
🤖 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/extractor_tag.go` around lines 174 - 178, Update
the resolveExtractorChatTarget error branch in runAutoTags to return in.chunks
instead of an empty slice, while preserving the existing nil error and warning
log so failed target resolution skips tagging without discarding content.

Comment on lines +351 to +357
common.Info(fmt.Sprintf("try to chat with message: %v", req.Messages))
if err := ctx.Err(); err != nil {
return nil, err
}
out, err := wrapper.Generate(ctx, toExtractorEinoMessages(req.Messages))
if err != nil {
common.Error(fmt.Sprintf("error when chat with message: %v", req.Messages), err)

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.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Avoid logging full request messages on every chat call.

Lines 351 and 357 log req.Messages verbatim at Info/Error level. These messages carry the system prompt plus chunk/document text sent to the LLM, so this can leak user content into logs and produce very large log lines on every invocation. Consider logging only counts/sizes (e.g. number of messages, total length) or gating full content behind a debug flag.

🔒 Suggested change
-	common.Info(fmt.Sprintf("try to chat with message: %v", req.Messages))
+	common.Info(fmt.Sprintf("extractor: chat: sending %d messages", len(req.Messages)))
 	if err := ctx.Err(); err != nil {
 		return nil, err
 	}
 	out, err := wrapper.Generate(ctx, toExtractorEinoMessages(req.Messages))
 	if err != nil {
-		common.Error(fmt.Sprintf("error when chat with message: %v", req.Messages), err)
+		common.Error(fmt.Sprintf("extractor: chat: generate failed (%d messages)", len(req.Messages)), err)
 		return nil, err
 	}
📝 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
common.Info(fmt.Sprintf("try to chat with message: %v", req.Messages))
if err := ctx.Err(); err != nil {
return nil, err
}
out, err := wrapper.Generate(ctx, toExtractorEinoMessages(req.Messages))
if err != nil {
common.Error(fmt.Sprintf("error when chat with message: %v", req.Messages), err)
common.Info(fmt.Sprintf("extractor: chat: sending %d messages", len(req.Messages)))
if err := ctx.Err(); err != nil {
return nil, err
}
out, err := wrapper.Generate(ctx, toExtractorEinoMessages(req.Messages))
if err != nil {
common.Error(fmt.Sprintf("extractor: chat: generate failed (%d messages)", len(req.Messages)), err)
🤖 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/extractor.go` around lines 351 - 357, Update the
chat logging around wrapper.Generate to stop including req.Messages content at
Info or Error level. Log only safe metadata such as message count and total
content size, while preserving the existing error context and generation
behavior.

Comment on lines +368 to +379
case "list":
for _, item := range el.Items {
text := extractTextFromListItem(item)
if text == "" {
continue
}
sections = append(sections, map[string]any{
"text": text,
"image": nil,
"doc_type_kwd": "text",
})
}

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 nested list content.

Only direct el.Items are emitted; docxIRListItem.Nested at Line 440 is never decoded, so nested DOCX bullets are silently dropped. Recursively emit nested lists and add a nested-list regression fixture.

As per coding guidelines, remove “move later” paths and collapse transitional implementations.

Also applies to: 437-440

🤖 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/docx_parser.go` around lines 368 - 379, Update the
list handling around extractTextFromListItem and docxIRListItem.Nested so nested
list items are recursively decoded and emitted as sections, preserving their
order and text instead of processing only direct el.Items. Collapse any
transitional “move later” path while implementing the recursive traversal, and
add a regression fixture covering nested DOCX bullets.

Source: Coding guidelines

@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/hierarchy_test.go (1)

334-339: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Remove migration-history prose from test comments.

Describe the required rune-aware behavior only; references to the previous byte-offset bug and “with/without fix” paths will become stale.

As per coding guidelines, keep package and documentation comments aligned with the current runtime path rather than migration history.

Also applies to: 373-377, 403-404, 410-415, 441-442

🤖 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/hierarchy_test.go` around lines 334 -
339, Update the comments in the affected hierarchy tests, including
TestIsColonTitle_CJKEdgeCase, to describe only the required rune-aware behavior
and expected outcomes. Remove references to prior byte-offset bugs, fixes,
migration history, or alternative execution paths while preserving the test
intent and threshold details.

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/hierarchy_test.go`:
- Around line 334-339: Update the comments in the affected hierarchy tests,
including TestIsColonTitle_CJKEdgeCase, to describe only the required rune-aware
behavior and expected outcomes. Remove references to prior byte-offset bugs,
fixes, migration history, or alternative execution paths while preserving the
test intent and threshold details.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 0db99ff7-0269-4d1a-8578-bfe415942bc4

📥 Commits

Reviewing files that changed from the base of the PR and between cc667c8 and 1719731.

📒 Files selected for processing (5)
  • internal/ingestion/component/chunker/hierarchy_test.go
  • internal/ingestion/component/chunker/title.go
  • internal/ingestion/component/extractor.go
  • internal/ingestion/component/extractor_tag.go
  • internal/ingestion/component/extractor_test.go
🚧 Files skipped from review as they are similar to previous changes (2)
  • internal/ingestion/component/chunker/title.go
  • internal/ingestion/component/extractor.go

@yuzhichang

Copy link
Copy Markdown
Member

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants