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.
Python agentagentic-aiagentic-frameworkagentic-workflowaiautomationclaudedeepseekgenaigptllmlow-codemcpnextjsno-codeopenaipythonskillsworkflow
fix: use node factory for single-step workflow nodes (#30859)
非法操作837237aa6d00
diff --git a/api/core/workflow/workflow_entry.py b/api/core/workflow/workflow_entry.pyindex ddf545bb345..fd3fc02f62b 100644--- a/api/core/workflow/workflow_entry.py+++ b/api/core/workflow/workflow_entry.py@@ -19,6 +19,7 @@ from core.workflow.graph_engine.protocols.command_channel import CommandChannelfrom core.workflow.graph_events import GraphEngineEvent, GraphNodeEventBase, GraphRunFailedEventfrom core.workflow.nodes import NodeTypefrom core.workflow.nodes.base.node import Node+from core.workflow.nodes.node_factory import DifyNodeFactoryfrom core.workflow.nodes.node_mapping import NODE_TYPE_CLASSES_MAPPINGfrom core.workflow.runtime import GraphRuntimeState, VariablePoolfrom core.workflow.system_variable import SystemVariable@@ -136,13 +137,11 @@ class WorkflowEntry::param user_inputs: user inputs:return:"""- node_config = workflow.get_node_config_by_id(node_id)+ node_config = dict(workflow.get_node_config_by_id(node_id))node_config_data = node_config.get("data", {})- # Get node class+ # Get node typenode_type = NodeType(node_config_data.get("type"))- node_version = node_config_data.get("version", "1")- node_cls = NODE_TYPE_CLASSES_MAPPING[node_type][node_version]# init graph init params and runtime stategraph_init_params = GraphInitParams(@@ -158,12 +157,12 @@ class WorkflowEntry:graph_runtime_state = GraphRuntimeState(variable_pool=variable_pool, start_at=time.perf_counter())# init workflow run state- node = node_cls(- id=str(uuid.uuid4()),- config=node_config,+ node_factory = DifyNodeFactory(graph_init_params=graph_init_params,graph_runtime_state=graph_runtime_state,)+ node = node_factory.create_node(node_config)+ node_cls = type(node)try:# variable selector to variable mappingdiff --git a/api/tests/unit_tests/core/workflow/test_workflow_entry.py b/api/tests/unit_tests/core/workflow/test_workflow_entry.pyindex 68d6c109e89..b38e070ffcd 100644--- a/api/tests/unit_tests/core/workflow/test_workflow_entry.py+++ b/api/tests/unit_tests/core/workflow/test_workflow_entry.py@@ -2,13 +2,17 @@ from types import SimpleNamespaceimport pytest+from configs import dify_configfrom core.file.enums import FileTypefrom core.file.models import File, FileTransferMethod+from core.helper.code_executor.code_executor import CodeLanguagefrom core.variables.variables import StringVariablefrom core.workflow.constants import (CONVERSATION_VARIABLE_NODE_ID,ENVIRONMENT_VARIABLE_NODE_ID,)+from core.workflow.nodes.code.code_node import CodeNode+from core.workflow.nodes.code.limits import CodeNodeLimitsfrom core.workflow.runtime import VariablePoolfrom core.workflow.system_variable import SystemVariablefrom core.workflow.workflow_entry import WorkflowEntry@@ -96,6 +100,58 @@ class TestWorkflowEntry:assert output_var is not Noneassert output_var.value == "system_user"+ def test_single_step_run_injects_code_limits(self):+ """Ensure single-step CodeNode execution configures limits."""+ # Arrange+ node_id = "code_node"+ node_data = {+ "type": "code",+ "title": "Code",+ "desc": None,+ "variables": [],+ "code_language": CodeLanguage.PYTHON3,+ "code": "def main():\n return {}",+ "outputs": {},+ }+ node_config = {"id": node_id, "data": node_data}++ class StubWorkflow:+ def __init__(self):+ self.tenant_id = "tenant"+ self.app_id = "app"+ self.id = "workflow"+ self.graph_dict = {"nodes": [node_config], "edges": []}++ def get_node_config_by_id(self, target_id: str):+ assert target_id == node_id+ return node_config++ workflow = StubWorkflow()+ variable_pool = VariablePool(system_variables=SystemVariable.empty(), user_inputs={})+ expected_limits = CodeNodeLimits(+ max_string_length=dify_config.CODE_MAX_STRING_LENGTH,+ max_number=dify_config.CODE_MAX_NUMBER,+ min_number=dify_config.CODE_MIN_NUMBER,+ max_precision=dify_config.CODE_MAX_PRECISION,+ max_depth=dify_config.CODE_MAX_DEPTH,+ max_number_array_length=dify_config.CODE_MAX_NUMBER_ARRAY_LENGTH,+ max_string_array_length=dify_config.CODE_MAX_STRING_ARRAY_LENGTH,+ max_object_array_length=dify_config.CODE_MAX_OBJECT_ARRAY_LENGTH,+ )++ # Act+ node, _ = WorkflowEntry.single_step_run(+ workflow=workflow,+ node_id=node_id,+ user_id="user",+ user_inputs={},+ variable_pool=variable_pool,+ )++ # Assert+ assert isinstance(node, CodeNode)+ assert node._limits == expected_limits+def test_mapping_user_inputs_to_variable_pool_with_env_variables(self):"""Test mapping environment variables from user inputs to variable pool."""# Initialize variable pool with environment variables