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(api/nodes): Fallback to `get_any` in some nodes that use object or array. (#6566)

-LAN-cfc408095cdf
diff --git a/api/core/workflow/nodes/code/code_node.py b/api/core/workflow/nodes/code/code_node.py
index b2c362b983c..fafd43e5bc9 100644
--- a/api/core/workflow/nodes/code/code_node.py
+++ b/api/core/workflow/nodes/code/code_node.py
@@ -59,8 +59,9 @@ class CodeNode(BaseNode):
variables = {}
for variable_selector in node_data.variables:
variable = variable_selector.variable
- value = variable_pool.get(variable_selector.value_selector)
- variables[variable] = value.value if value else None
+ value = variable_pool.get_any(variable_selector.value_selector)
+
+ variables[variable] = value
# Run code
try:
result = CodeExecutor.execute_workflow_code_template(
diff --git a/api/core/workflow/nodes/end/end_node.py b/api/core/workflow/nodes/end/end_node.py
index 17488f72531..440dfa2f271 100644
--- a/api/core/workflow/nodes/end/end_node.py
+++ b/api/core/workflow/nodes/end/end_node.py
@@ -24,8 +24,8 @@ class EndNode(BaseNode):
outputs = {}
for variable_selector in output_variables:
- value = variable_pool.get(variable_selector.value_selector)
- outputs[variable_selector.variable] = value.value if value else None
+ value = variable_pool.get_any(variable_selector.value_selector)
+ outputs[variable_selector.variable] = value
return NodeRunResult(
status=WorkflowNodeExecutionStatus.SUCCEEDED,
diff --git a/api/core/workflow/nodes/http_request/http_executor.py b/api/core/workflow/nodes/http_request/http_executor.py
index 473d85f073d..3c24c0a018d 100644
--- a/api/core/workflow/nodes/http_request/http_executor.py
+++ b/api/core/workflow/nodes/http_request/http_executor.py
@@ -333,13 +333,13 @@ class HttpExecutor:
if variable_pool:
variable_value_mapping = {}
for variable_selector in variable_selectors:
- variable = variable_pool.get(variable_selector.value_selector)
+ variable = variable_pool.get_any(variable_selector.value_selector)
if variable is None:
raise ValueError(f'Variable {variable_selector.variable} not found')
- if escape_quotes and isinstance(variable.value, str):
- value = variable.value.replace('"', '\\"')
+ if escape_quotes and isinstance(variable, str):
+ value = variable.replace('"', '\\"')
else:
- value = variable.value
+ value = variable
variable_value_mapping[variable_selector.variable] = value
return variable_template_parser.format(variable_value_mapping), variable_selectors
diff --git a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py
index 6e1534b3c2c..ccd45d13833 100644
--- a/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py
+++ b/api/core/workflow/nodes/knowledge_retrieval/knowledge_retrieval_node.py
@@ -41,8 +41,8 @@ class KnowledgeRetrievalNode(BaseNode):
node_data: KnowledgeRetrievalNodeData = cast(self._node_data_cls, self.node_data)
# extract variables
- variable = variable_pool.get(node_data.query_variable_selector)
- query = variable.value if variable else None
+ variable = variable_pool.get_any(node_data.query_variable_selector)
+ query = variable
variables = {
'query': query
}
diff --git a/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py b/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py
index 1fe6896e891..2876695a825 100644
--- a/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py
+++ b/api/core/workflow/nodes/parameter_extractor/parameter_extractor_node.py
@@ -71,10 +71,10 @@ class ParameterExtractorNode(LLMNode):
Run the node.
"""
node_data = cast(ParameterExtractorNodeData, self.node_data)
- variable = variable_pool.get(node_data.query)
+ variable = variable_pool.get_any(node_data.query)
if not variable:
raise ValueError("Input variable content not found or is empty")
- query = variable.value
+ query = variable
inputs = {
'query': query,
@@ -565,8 +565,8 @@ class ParameterExtractorNode(LLMNode):
variable_template_parser = VariableTemplateParser(instruction)
inputs = {}
for selector in variable_template_parser.extract_variable_selectors():
- variable = variable_pool.get(selector.value_selector)
- inputs[selector.variable] = variable.value if variable else None
+ variable = variable_pool.get_any(selector.value_selector)
+ inputs[selector.variable] = variable
return variable_template_parser.format(inputs)
diff --git a/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py b/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py
index 1e494760668..885f7d76170 100644
--- a/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py
+++ b/api/core/workflow/nodes/variable_aggregator/variable_aggregator_node.py
@@ -20,26 +20,26 @@ class VariableAggregatorNode(BaseNode):
if not node_data.advanced_settings or not node_data.advanced_settings.group_enabled:
for selector in node_data.variables:
- variable = variable_pool.get(selector)
+ variable = variable_pool.get_any(selector)
if variable is not None:
outputs = {
- "output": variable.value
+ "output": variable
}
inputs = {
- '.'.join(selector[1:]): variable.value
+ '.'.join(selector[1:]): variable
}
break
else:
for group in node_data.advanced_settings.groups:
for selector in group.variables:
- variable = variable_pool.get(selector)
+ variable = variable_pool.get_any(selector)
if variable is not None:
outputs[group.group_name] = {
- 'output': variable.value
+ 'output': variable
}
- inputs['.'.join(selector[1:])] = variable.value
+ inputs['.'.join(selector[1:])] = variable
break
return NodeRunResult(