Repository navigation
Drop unscoped (flat) parser_config keys instead of rejecting them - #20445
Conversation
The Go backend enforces a component-scoped-only contract for parser_config: every top-level key must be keyed by a component id (contain ":"), e.g. "Parser:abc123". Previously a flat key such as the single File input node (id "File") was rejected with an error, which breaks requests that still carry legacy or single-instance flat keys. Flat keys are legacy transport artifacts that downstream consumers (CleanComponentParams) never read, so they are now silently dropped rather than rejected. All three entry points (dataset create, dataset update, document change_parser) drop such keys and log a warning that includes the dropped key names and request context (tenant/dataset/user id) for traceability. The size limit is still enforced.
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (1)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughParser configuration validation removes top-level keys without ChangesParser Configuration Filtering
Priority: ⬇️ Low Estimated code review effort: 3 (Moderate) | ~20 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to The reviewed test changes look safe to merge. The parser-config filtering itself is covered only by the author-reported test run. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Component-scoped processing and ownership checks remain intact. The main risk is that discarded input is excluded from configuration-size validation while its complete key names are logged, potentially increasing shared logging costs. The effective exposure depends on request and logging limits that were not established. Retained concerns
Security review detailsSecurity Blast Radius
Security Findings and Attack Paths
Trust Boundaries and Controls
Resilience and Maintainability Implications
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 key, Comment |
Previously the three entry points dropped unscoped (flat) parser_config keys via DropUnscopedParserConfigKeys and then validated the size limit in two different ways: crud/update called validateDatasetParserConfigSize directly, while document called ValidateDocumentParserConfig, which dropped the keys again — a redundant double drop. Make ValidateParserConfig and ValidateDocumentParserConfig return the names of the dropped keys ([]string, error) so every entry path shares a single drop call and a single logging site. This removes the redundant drop in the document path and gives ValidateParserConfig a production caller (it was only referenced by tests before). Tests updated to the new signature; two new tests assert the returned dropped-key list.
…act tests PR infiniflow#20445 changed the Go backend to silently drop (rather than reject) component-unscoped flat parser_config keys with code 0. Update the two contract tests that still asserted the old code-101 rejection: - test_dataset_update_parser_config_valid_matrix_contract: all cases are flat keys, so assert code 0 and that the dropped keys do not survive in the stored config. - test_dataset_update_parser_config_invalid_values_contract: flat keys are dropped before field validation, so assert code 0 instead of the field-level error message. The Python (non-Go) branches are dead code: CI always runs with API_PROXY_SCHEME="go" (sep-tests.yml api_proxy_schemes=["go"]) and the Python backend has been removed from main, so they are removed entirely. Co-authored-by: xugangqiang <[email protected]>
… ones Go no longer accepts legacy flat parser_config (the create-path tests already skip it for Go), so the two update-path contract tests that asserted the old code-101 rejection are rewritten to match: - test_dataset_update_parser_config_valid_matrix_contract and test_dataset_update_parser_config_invalid_contract now pytest.skip for Go (consistent with the create-path convention). They keep their Python round-trip/validation assertions as documentation but never run under CI, which is always API_PROXY_SCHEME="go" since the Python backend was removed from main. The intended component-scoped contract is covered by two new tests: - test_dataset_update_parser_config_component_scoped_roundtrip: discovers the real chunker component id from a created dataset and verifies a dataset-level parent_child setting reaches the runtime chunker node and round-trips (children_delimiters list). - test_dataset_update_parser_config_accepts_bare_file_node: the DSL emits a single input node keyed by the bare id "File" (no colon); the Go backend tolerates it (dropped server-side) instead of rejecting with 101, which is the back-compat fix from PR infiniflow#20445. Co-authored-by: xugangqiang <[email protected]>
9d017d2 to
36420e0
Compare
… ones Go no longer accepts legacy flat parser_config (the create-path tests already skip it for Go), so the two update-path contract tests that asserted the old code-101 rejection are rewritten to match: - test_dataset_update_parser_config_valid_matrix_contract and test_dataset_update_parser_config_invalid_contract now pytest.skip for Go (consistent with the create-path convention). They keep their Python round-trip/validation assertions as documentation but never run under CI, which is always API_PROXY_SCHEME="go" since the Python backend was removed from main. The intended component-scoped contract is covered by two new tests: - test_dataset_update_parser_config_component_scoped_roundtrip: discovers the real chunker component id from a created dataset and verifies a dataset-level parent_child setting reaches the runtime chunker node and round-trips (children_delimiters list). - test_dataset_update_parser_config_accepts_bare_file_node: the DSL emits a single input node keyed by the bare id "File" (no colon); the Go backend tolerates it (dropped server-side) instead of rejecting with 101, which is the back-compat fix from PR infiniflow#20445. Co-authored-by: xugangqiang <[email protected]>
36420e0 to
7c39a38
Compare
Summary
The Go backend enforces a component-scoped-only contract for
parser_config: every top-level key must be keyed by a component id (contain":"), e.g."Parser:abc123". Previously any flat (non-component-scoped) key was rejected with an error. This breaks requests that still carry legacy or single-instance flat keys — most notably theFileinput node, whose id is the bare name"File"(a DSL has exactly one File instance, so it is never scoped asFile:<id>).Flat keys are legacy transport artifacts that downstream consumers (
CleanComponentParams) never read, so rejecting them was stricter than the actual processing. This change drops such keys and logs a warning instead of failing the request.What changed
DropUnscopedParserConfigKeys(internal/service/dataset/helpers.go): removes top-level keys that do not contain":"and returns the dropped key names. Only top-level keys are affected; keys nested inside a component node (e.g."Extractor:AutoExtractDefault.metadata") are preserved.ValidateParserConfig/ValidateDocumentParserConfignow drop flat keys and still enforce the size limit (they no longer return an error for flat keys).tenant_iddataset_id,tenant_iduser_id,dataset_id,document_idWhy a warning, not silent
The dropped key names and request context are logged so misbehaving clients (or stale saved configs) are traceable via the warning rather than silently changing behavior without a signal.
Test plan
TestDropUnscopedParserConfigKeyscovering: nil/empty maps, top-level flat-key removal, preservation of component-scoped keys, and preservation of nested flat-looking keys inside a component node.bash build.sh --test ./internal/service/dataset/... ./internal/handler/...passes.Note for reviewers
This is a deliberate relaxation of the strict validation contract (previously fail-fast on flat keys) into lenient drop + warn. It is intended as a stopgap for existing/legacy flat keys (e.g. the
Filenode); the long-term direction remains component-scoped config. The size limit onparser_configis unchanged.