Skip to content

Fix: 1. update document parser_config does not clean chunks, 2. after update, pop up dialog to notice use to re-parse - #21281

Merged
yuzhichang merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-update-parser_config-does-not-clean-chunks-double-comfirm-to-reparse
Oct 21, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-update-parser_config-does-not-clean-chunks-double-comfirm-to-reparse

Conversation

@wangq8

@wangq8 wangq8 commented Oct 21, 2026

Copy link
Copy Markdown
Collaborator
  1. update document parser_config should leave the chunks as it is, DO NOT clean the chunks or any generated data
  2. when update document parser_config, when there is chunks for the document, pop up a dialog to ask user to see if want to re-parse the document.

@wangq8 wangq8 added the ci Continue Integration label Oct 21, 2026
@coderabbitai

coderabbitai Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 7802fbfc-c212-40e8-b350-0bb700fa27ab
📥 Commits

Reviewing files that changed from the base of the PR and between aae7f15 and ce12503.

📒 Files selected for processing: 8
  • docs/references/http_api_reference.md
  • internal/service/document/document_dataset_update.go
  • internal/service/document/document_parse.go
  • internal/service/document/document_test.go
  • web/src/locales/en.ts
  • web/src/locales/zh.ts
  • web/src/pages/dataset/dataset/change-parser-dialog.test.tsx
  • web/src/pages/dataset/dataset/use-change-document-parser.ts
💤 Files with no reviewable changes: 1
  • internal/service/document/document_parse.go

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

📝 Walkthrough

Parser-setting updates now save selections without clearing existing parse results. For documents with existing chunks, the UI offers a confirmation to clear and re-parse. Confirmed runs enable deletion and disable knowledge-base application.

Changes: Parser settings and reparse flow

Layer / File(s) Summary
Save parser settings without resetting results
internal/service/document/document_dataset_update.go, internal/service/document/document_parse.go, internal/service/document/document_test.go, docs/references/http_api_reference.md
Parser and pipeline selections are saved directly without resetting existing parse results. Tests verify that parser settings update while parse state, counters, chunks, and completed tasks remain unchanged. The API reference documents that changes take effect on a later, explicit parse.
Offer reparse after parser changes
web/src/pages/dataset/dataset/use-change-document-parser.ts, web/src/pages/dataset/dataset/change-parser-dialog.test.tsx, web/src/locales/en.ts, web/src/locales/zh.ts
After a successful parser update, the UI offers reparse confirmation when the document has existing chunks. Confirmation runs the document with deletion enabled and knowledge-base application disabled. Tests cover confirmation, decline, save failure, and built-in parser behavior.

Priority: ⬇️ Low

Estimated code review effort: 3 (Moderate) | ~20 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant useChangeDocumentParser
  participant runDocumentByIds
  useChangeDocumentParser->>User: Show reparse confirmation
  User->>useChangeDocumentParser: Confirm reparse
  useChangeDocumentParser->>runDocumentByIds: Run with deletion enabled and apply_kb disabled
Loading

Suggested reviewers: buua436, xugangqiang

Merge Risk: ⚪ Minimal · up to ce125

Parser settings can be saved without discarding existing results, and confirmed re-parsing uses the saved settings. No merge-blocking issue was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 files. (1 skipped: 1 … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly describes both main changes: preserving chunks when updating parser configuration and prompting the user to re-parse.
Description check Passed The description explains both requested behavior changes and matches the pull request objectives. It does not use the required "### Summary" heading, but the required information is present.
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 3 functions across 6 files. (1 skipped: 1 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

❤️ Share

A rabbit checks the parser’s tune,
Old chunks stay beneath the moon.
“Reparse?” the little dialog asks,
The rabbit hops to confirm the task.
New settings wait for chunks to renew.

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

@yuzhichang yuzhichang left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed at ce12503 against merge-base b6252ef. The backend change does what the description claims: UpdateDatasetDocument now persists parser_id/pipeline_id/parser_config and no longer touches chunks, chunk images, counters, progress, or the ingestion task. Access control still resolves the dataset via CheckDatasetAccess + kbDAO.GetByID, and the document is re-fetched with GetByDocumentIDAndDatasetID, so the write is scoped to the right tenant/dataset. Removing resetDocumentForReparse, decrementDocumentAndKBCountersForReparse, and the local deleteChunkImages helper leaves exactly one cleanup path (clearDocumentParseResults, reached only through an explicit re-parse with delete: true); no caller was left dangling, and deleteDocumentChunkImages is still used by that path. The new Go test asserts the preservation contract for five request shapes and also asserts the doc engine is never touched.

Coverage: 8/8 files reviewed, 0 skipped. OCR reviewable 5/5 (document_dataset_update.go, document_parse.go, en.ts, zh.ts, use-change-document-parser.ts); the 3 OCR-excluded files (http_api_reference.md, document_test.go, change-parser-dialog.test.tsx) were read manually.

Verification: bash build.sh --cpp then bash build.sh --test ./internal/service/document/... passes. npx jest src/pages/dataset/dataset/change-parser-dialog.test.tsx passes 8/8. The new API doc sentence matches the implemented behavior.

Severity counts: P1 0, P2 1, P3 1.

No unresolved P1/major finding. The P2 is confined to the newly added re-parse shortcut and does not block the settings-preservation change itself, but it is the one flow in this PR that can lose data and should be fixed before merge.

cancelText: t('common.no'),
onOk: async () => {
try {
await runDocumentByIds({

@yuzhichang yuzhichang Oct 21, 2026 •

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.

[P2] This confirmation path calls runDocumentByIds directly, so it skips the parser-gap validation that every other parse start performs (useHandleRunDocumentByIds → findDocumentParseGaps → blocked modal telling the user to reselect the parser). The dialog lets a user save any built-in parser, and validateDatasetDocumentUpdate only rejects a mismatched parser for visual/presentation files, so switching a video/audio/image document to a parser whose setups do not declare that family is accepted here.

The request then goes out with delete: true, and StartParseDocuments calls clearDocumentParseResults before the worker parses. For a video whose new config has no video setup, maybeDispatchVideo declines and dispatchParse → parser.GetParser(FileTypeVIDEO) returns unsupported file type: video, so the document ends with zero chunks and a failed task. For audio/image the parse succeeds but emits no text when the family is undeclared, which silently replaces a good parse with an empty one. Both are recoverable by restoring the parser and re-parsing, but the standard parse button blocks this state explicitly. Route this confirmation through useHandleRunDocumentByIds, or run findDocumentParseGaps and surface the same blocked/partial modal, before deleting.

});
if (ret === 0) {
hideChangeParserModal();
if (record.chunk_count > 0) {

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.

[P3] The prompt is gated only on record.chunk_count > 0, not on whether the submitted selection/config differs from what is saved. Opening the parser dialog and pressing Save without editing anything still offers to clear all chunks and re-parse, and confirming deletes them and pays for a full re-parse. Comparing parserConfigInfo (parser_id/pipeline_id/parser_config) against record.chunk_method/record.pipeline_id/record.parser_config before showing the confirm would avoid the no-op prompt.

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

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants