Repository navigation
fix(document): clone parser_config to break dataset aliasing; drop dead parser-config helpers - #20381
Conversation
Document upload (both file2document and sync_document) previously passed kb.ParserConfig directly, or copyJSONMap()'d it shallowly, to resolveDocumentParser. resolveDocumentParser keeps the base map on the no-parser-switch path, so the resulting document.ParserConfig nested maps were the same maps the dataset row hands out. Writing a component entry into one document would leak into the dataset and every sibling document created from it. cloneParserConfigForDocument does a real deep copy via DeepMergeMaps. newDatasetDocument now calls it unconditionally as the safety net. copyJSONMap becomes dead and is removed. The snapshot branch also touched this file for table column mode; that logic (tableDocumentConfigForFile, table_column_names_by_file) is left in the feature branch, not here.
UpdateParserConfig, DeleteFieldMap and their deep-merge helper mergeConfig had no callers anywhere in internal/. The live dataset update path writes parser_config through the dataset/document services, so these DAO methods were leftover dead code.
The Python table chunker (rag/app/table.py) is gone, but the Go port's
comments still cited it by path — and cited a line number (:656) that no
longer maps to anything. Keep the provenance ("the Python table
chunker") without the dead path or line number.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (4)
💤 Files with no reviewable changes (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe changes remove two knowledge-base parser configuration methods and their merge helper. Document creation and file conversion now pass cloned parser configuration maps. Sync passes the knowledge base configuration directly. Tests cover clone isolation and sync with nil configuration. Table chunker comments no longer cite repository paths. ChangesParser Configuration Handling
Table Chunker Comments
Priority: ⬇️ Low Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The removed methods have no repository callers, and sync does not change the dataset’s parser configuration. No actionable issue remains before normal merge checks. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Document configuration is better isolated from its dataset, and no new authorization path was identified. An unusual parser-template failure could still alter the dataset configuration held in memory during sync; its production reachability is unconfirmed. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Hardening Proposals
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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. A rabbit checks each parser map, Comment |
Summary
This PR fixes document/dataset
parser_configaliasing in the Go document creation path and removes unused parser-config code.cloneParserConfigForDocumentusescommon.DeepMergeMapsto copy nested JSON maps and slices.newDatasetDocumentclones the resolved config for local, web, empty, and synced documents;file2document, which constructs its ownDocument, clones directly. A document can then change its component settings without changing the dataset or sibling documents.parser_configbecomes an independent empty object before writing the non-nulldocument.parser_configcolumn. The sync path relies on the clone innewDatasetDocument, avoiding a second copy. The previous sync helper also produced an empty object for a null input.KnowledgebaseDAOUpdateParserConfig,DeleteFieldMap, andmergeConfighelpers, and removerag/app/table.pypath and line references from table chunker comments.Related Issue
Split from #19347, which bundles the table column-mode feature together with the independent fixes above. This PR carries only those fixes so they can land without the feature; the column-mode work will be resubmitted separately, re-anchored on
main's current parser/chunking contract (67d68725fmadeparser_configcomponent-scoped with no flat-key compatibility, which superseded part of that branch's premise).Changes
internal/service/document: deep-copy document configs, normalize null dataset configs to empty document configs, removecopyJSONMap, and cover nested isolation and the full synced-document insert path with unit tests.internal/dao/kb.go: remove unused parser-config helpers.internal/ingestion/component/chunker/table.goand its test: remove stale Python file references from comments.Test Plan
bash build.sh --test ./internal/service/document/... ./internal/dao/... ./internal/ingestion/component/chunker/...— all three packages pass on the updated branch; the script's native unit tests pass too.TestSyncDocumentUpsertWithNilDatasetParserConfigreproduces the previousNOT NULL constraint failed: document.parser_configerror before the fix and verifies that a synced document now persists an empty JSON object.bash build.sh --cppbefore the Go tests iflibrag_tokenizer_c_api.ahas not been built.