mirror of
https://github.com/langgenius/dify.git
synced 2024-11-16 11:42:29 +08:00
feat(workflow-nodes): handle missing variables without failure (#10471)
This commit is contained in:
parent
445dcfe4d0
commit
bf31a3efbc
|
@ -49,13 +49,7 @@ class CodeNode(BaseNode[CodeNodeData]):
|
||||||
for variable_selector in self.node_data.variables:
|
for variable_selector in self.node_data.variables:
|
||||||
variable_name = variable_selector.variable
|
variable_name = variable_selector.variable
|
||||||
variable = self.graph_runtime_state.variable_pool.get(variable_selector.value_selector)
|
variable = self.graph_runtime_state.variable_pool.get(variable_selector.value_selector)
|
||||||
if variable is None:
|
variables[variable_name] = variable.to_object() if variable else None
|
||||||
return NodeRunResult(
|
|
||||||
status=WorkflowNodeExecutionStatus.FAILED,
|
|
||||||
inputs=variables,
|
|
||||||
error=f"Variable `{variable_selector.value_selector}` not found",
|
|
||||||
)
|
|
||||||
variables[variable_name] = variable.to_object()
|
|
||||||
# Run code
|
# Run code
|
||||||
try:
|
try:
|
||||||
result = CodeExecutor.execute_workflow_code_template(
|
result = CodeExecutor.execute_workflow_code_template(
|
||||||
|
|
|
@ -34,12 +34,7 @@ class TemplateTransformNode(BaseNode[TemplateTransformNodeData]):
|
||||||
for variable_selector in self.node_data.variables:
|
for variable_selector in self.node_data.variables:
|
||||||
variable_name = variable_selector.variable
|
variable_name = variable_selector.variable
|
||||||
value = self.graph_runtime_state.variable_pool.get(variable_selector.value_selector)
|
value = self.graph_runtime_state.variable_pool.get(variable_selector.value_selector)
|
||||||
if value is None:
|
variables[variable_name] = value.to_object() if value else None
|
||||||
return NodeRunResult(
|
|
||||||
status=WorkflowNodeExecutionStatus.FAILED,
|
|
||||||
error=f"Variable {variable_name} not found in variable pool",
|
|
||||||
)
|
|
||||||
variables[variable_name] = value.to_object()
|
|
||||||
# Run code
|
# Run code
|
||||||
try:
|
try:
|
||||||
result = CodeExecutor.execute_workflow_code_template(
|
result = CodeExecutor.execute_workflow_code_template(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user