fix: normalize disabled summary_index_setting to prevent validation error#37547
Open
ifer47 wants to merge 1 commit into
Open
fix: normalize disabled summary_index_setting to prevent validation error#37547ifer47 wants to merge 1 commit into
ifer47 wants to merge 1 commit into
Conversation
…rror
When the "Summary Generation Auto" switch is turned off, the frontend
sends {"enable": false, "model_name": null, ...}. The existing
normalize_summary_index_setting validator only handled enable=None but
not enable=False, causing SummaryIndexSettingDict TypedDict validation
to reject None values for NotRequired[str] fields.
Extend the validator to treat enable=False the same as enable=None,
and add normalization at all DB write paths so disabled settings are
never persisted with None string values.
Refs langgenius#37209, langgenius#36233.
Co-Authored-By: zhipu/glm-5 <zai-org@claude-code-best.win>
Contributor
Pyrefly Diffbase → PR--- /tmp/pyrefly_base.txt 2026-06-16 19:22:34.953510928 +0000
+++ /tmp/pyrefly_pr.txt 2026-06-16 19:22:26.707434165 +0000
@@ -5575,7 +5575,7 @@
ERROR Argument `dict[str, list[str] | str]` is not assignable to parameter `node_data` with type `KnowledgeIndexNodeData | dict[str, object]` in function `_build_node` [bad-argument-type]
--> tests/unit_tests/core/workflow/nodes/knowledge_index/test_knowledge_index_node.py:140:23
ERROR Argument `dict[str, bool]` is not assignable to parameter `summary_index_setting` with type `SummaryIndexSettingDict | None` in function `core.workflow.nodes.knowledge_index.knowledge_index_node.KnowledgeIndexNode._invoke_knowledge_index` [bad-argument-type]
- --> tests/unit_tests/core/workflow/nodes/knowledge_index/test_knowledge_index_node.py:661:35
+ --> tests/unit_tests/core/workflow/nodes/knowledge_index/test_knowledge_index_node.py:767:35
ERROR `None` is not subscriptable [unsupported-operation]
--> tests/unit_tests/core/workflow/nodes/knowledge_retrieval/test_knowledge_retrieval_node.py:644:16
ERROR `None` is not subscriptable [unsupported-operation]
|
Contributor
Pyrefly Type Coverage
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{"enable": false, "model_name": null, ...}, but the existingnormalize_summary_index_settingvalidator only handledenable=None, notenable=FalseSummaryIndexSettingDictTypedDict validation to rejectNonevalues forNotRequired[str]fields, resulting in a 4-fieldValidationErrorwhen running knowledge pipeline workflowsnormalize_summary_index_settingvalidators to treatenable=Falsethe same asenable=None(collapse toNone)_normalize_summary_index_setting_value()helper and applied it at all DB write paths so disabled settings are never persisted withNonestring valuesChanges
entities.py— ExtendedKnowledgeIndexNodeData.normalize_summary_index_settingto also handleenable=Falsedataset_service.py— Extended 3 Pydantic validators (_AutomaticProcessRule,_CustomProcessRule,_HierarchicalProcessRule); added_normalize_summary_index_setting_value()helper; normalized 5 DB write pathsrag_pipeline_dsl_service.py— Normalized 2 DB write paths using the helperrag_pipeline_transform_service.py— Normalized workflow node copy pathtest_knowledge_index_node.py— AddedTestSummaryIndexSettingNormalizationwith 6 test casesFixes #37209
Refs #36233
Test plan
summary_index_settingstored as{"enable": false, "model_name": null, ...}— verify workflow runs without errorenable=Truesettings are still preserved correctlypytest api/tests/unit_tests/core/workflow/nodes/knowledge_index/test_knowledge_index_node.py -k TestSummaryIndexSettingNormalization🤖 Generated with Claude Code Best