Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

fix: normalize summary_index_setting None to fix preview error (#36626)

Evan4d6f8eba2a86
diff --git a/api/services/dataset_service.py b/api/services/dataset_service.py
index ea8896a5aab..1332390d46a 100644
--- a/api/services/dataset_service.py
+++ b/api/services/dataset_service.py
@@ -170,6 +170,16 @@ class _AutomaticProcessRule(BaseModel):
mode: Literal[ProcessRuleMode.AUTOMATIC]
summary_index_setting: _SummaryIndexSetting | None = None
+ @field_validator("summary_index_setting", mode="before")
+ @classmethod
+ def _normalize_summary_index_setting(cls, v: Any) -> Any:
+ """Treat dicts with enable=None (or missing enable) as None (#36602)."""
+ if v is None:
+ return None
+ if isinstance(v, dict) and v.get("enable") is None:
+ return None
+ return v
+
class _CustomProcessRule(BaseModel):
model_config = ConfigDict(extra="allow")
@@ -178,6 +188,16 @@ class _CustomProcessRule(BaseModel):
rules: _EstimateRules
summary_index_setting: _SummaryIndexSetting | None = None
+ @field_validator("summary_index_setting", mode="before")
+ @classmethod
+ def _normalize_summary_index_setting(cls, v: Any) -> Any:
+ """Treat dicts with enable=None (or missing enable) as None (#36602)."""
+ if v is None:
+ return None
+ if isinstance(v, dict) and v.get("enable") is None:
+ return None
+ return v
+
class _HierarchicalProcessRule(BaseModel):
model_config = ConfigDict(extra="allow")
@@ -186,6 +206,16 @@ class _HierarchicalProcessRule(BaseModel):
rules: _EstimateRules
summary_index_setting: _SummaryIndexSetting | None = None
+ @field_validator("summary_index_setting", mode="before")
+ @classmethod
+ def _normalize_summary_index_setting(cls, v: Any) -> Any:
+ """Treat dicts with enable=None (or missing enable) as None (#36602)."""
+ if v is None:
+ return None
+ if isinstance(v, dict) and v.get("enable") is None:
+ return None
+ return v
+
_EstimateProcessRule = Annotated[
_AutomaticProcessRule | _CustomProcessRule | _HierarchicalProcessRule,