Skip to content

fix: normalize disabled summary_index_setting to prevent validation error#37547

Open
ifer47 wants to merge 1 commit into
langgenius:mainfrom
ifer47:fix/summary-index-setting-disabled-validation
Open

fix: normalize disabled summary_index_setting to prevent validation error#37547
ifer47 wants to merge 1 commit into
langgenius:mainfrom
ifer47:fix/summary-index-setting-disabled-validation

Conversation

@ifer47

@ifer47 ifer47 commented Jun 16, 2026

Copy link
Copy Markdown

Summary

  • When the "Summary Generation Auto" switch is turned off, the frontend sends {"enable": false, "model_name": null, ...}, but the existing normalize_summary_index_setting validator only handled enable=None, not enable=False
  • This caused SummaryIndexSettingDict TypedDict validation to reject None values for NotRequired[str] fields, resulting in a 4-field ValidationError when running knowledge pipeline workflows
  • Extended all normalize_summary_index_setting validators to treat enable=False the same as enable=None (collapse to None)
  • Added _normalize_summary_index_setting_value() helper and applied it at all DB write paths so disabled settings are never persisted with None string values

Changes

  1. entities.py — Extended KnowledgeIndexNodeData.normalize_summary_index_setting to also handle enable=False
  2. dataset_service.py — Extended 3 Pydantic validators (_AutomaticProcessRule, _CustomProcessRule, _HierarchicalProcessRule); added _normalize_summary_index_setting_value() helper; normalized 5 DB write paths
  3. rag_pipeline_dsl_service.py — Normalized 2 DB write paths using the helper
  4. rag_pipeline_transform_service.py — Normalized workflow node copy path
  5. test_knowledge_index_node.py — Added TestSummaryIndexSettingNormalization with 6 test cases

Fixes #37209
Refs #36233

Test plan

  • Create a dataset with "Summary Generation Auto" enabled, then disable it — verify no validation error
  • Run a knowledge pipeline workflow with a dataset that has summary_index_setting stored as {"enable": false, "model_name": null, ...} — verify workflow runs without error
  • Verify that enable=True settings are still preserved correctly
  • Run the new unit tests: pytest api/tests/unit_tests/core/workflow/nodes/knowledge_index/test_knowledge_index_node.py -k TestSummaryIndexSettingNormalization

🤖 Generated with Claude Code Best

…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>
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Jun 16, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Diff

base → 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]

@github-actions

Copy link
Copy Markdown
Contributor

Pyrefly Type Coverage

Metric Base PR Delta
Type coverage 48.59% 48.59% -0.01%
Strict coverage 48.10% 48.09% -0.00%
Typed symbols 27,995 27,995 0
Untyped symbols 29,922 29,928 +6
Modules 2892 2892 0

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

Labels

size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Knowledge pipeline summary gen auto enables before then disable got error

1 participant