Repository navigation
Fix: 1. update document parser_config does not clean chunks, 2. after update, pop up dialog to notice use to re-parse - #21281
Conversation
wangq8
commented
Oct 21, 2026
- update document parser_config should leave the chunks as it is, DO NOT clean the chunks or any generated data
- 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.
…pop up dialog to notice re-parse
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
yuzhichang
left a comment
There was a problem hiding this comment.
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({ |
There was a problem hiding this comment.
[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) { |
There was a problem hiding this comment.
[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.