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: if-else-node handles missing optional file variables (#15693)

Arcaner12fa517297a1
diff --git a/api/core/workflow/entities/variable_pool.py b/api/core/workflow/entities/variable_pool.py
index 844b46f3528..a0318083606 100644
--- a/api/core/workflow/entities/variable_pool.py
+++ b/api/core/workflow/entities/variable_pool.py
@@ -7,7 +7,7 @@ from pydantic import BaseModel, Field
from core.file import File, FileAttribute, file_manager
from core.variables import Segment, SegmentGroup, Variable
-from core.variables.segments import FileSegment
+from core.variables.segments import FileSegment, NoneSegment
from factories import variable_factory
from ..constants import CONVERSATION_VARIABLE_NODE_ID, ENVIRONMENT_VARIABLE_NODE_ID, SYSTEM_VARIABLE_NODE_ID
@@ -131,11 +131,13 @@ class VariablePool(BaseModel):
if attr not in {item.value for item in FileAttribute}:
return None
value = self.get(selector)
- if not isinstance(value, FileSegment):
+ if not isinstance(value, (FileSegment, NoneSegment)):
return None
- attr = FileAttribute(attr)
- attr_value = file_manager.get_attr(file=value.value, attr=attr)
- return variable_factory.build_segment(attr_value)
+ if isinstance(value, FileSegment):
+ attr = FileAttribute(attr)
+ attr_value = file_manager.get_attr(file=value.value, attr=attr)
+ return variable_factory.build_segment(attr_value)
+ return value
return value