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(workflow): fetch user failed when workflow run in parallel mode (#20321)
-LAN-f233a64eb562
diff --git a/api/core/app/apps/advanced_chat/app_generator.py b/api/core/app/apps/advanced_chat/app_generator.pyindex 50a843c7e86..fdd1a776f81 100644--- a/api/core/app/apps/advanced_chat/app_generator.py+++ b/api/core/app/apps/advanced_chat/app_generator.py@@ -452,7 +452,7 @@ class AdvancedChatAppGenerator(MessageBasedAppGenerator):for var, val in context.items():var.set(val)- # Save current user before entering new app context+ # FIXME(-LAN-): Save current user before entering new app contextfrom flask import gsaved_user = Nonediff --git a/api/core/app/apps/agent_chat/app_generator.py b/api/core/app/apps/agent_chat/app_generator.pyindex d5ee3243608..158196f24dc 100644--- a/api/core/app/apps/agent_chat/app_generator.py+++ b/api/core/app/apps/agent_chat/app_generator.py@@ -232,7 +232,7 @@ class AgentChatAppGenerator(MessageBasedAppGenerator):for var, val in context.items():var.set(val)- # Save current user before entering new app context+ # FIXME(-LAN-): Save current user before entering new app contextfrom flask import gsaved_user = Nonediff --git a/api/core/app/apps/workflow/app_generator.py b/api/core/app/apps/workflow/app_generator.pyindex 5442927413d..6ea90e5a3d2 100644--- a/api/core/app/apps/workflow/app_generator.py+++ b/api/core/app/apps/workflow/app_generator.py@@ -411,7 +411,7 @@ class WorkflowAppGenerator(BaseAppGenerator):for var, val in context.items():var.set(val)- # Save current user before entering new app context+ # FIXME(-LAN-): Save current user before entering new app contextfrom flask import gsaved_user = Nonediff --git a/api/core/workflow/graph_engine/graph_engine.py b/api/core/workflow/graph_engine/graph_engine.pyindex 36273d8ec15..f61965e07ec 100644--- a/api/core/workflow/graph_engine/graph_engine.py+++ b/api/core/workflow/graph_engine/graph_engine.py@@ -9,7 +9,7 @@ from copy import copy, deepcopyfrom datetime import UTC, datetimefrom typing import Any, Optional, cast-from flask import Flask, current_app+from flask import Flask, current_app, has_request_contextfrom configs import dify_configfrom core.app.apps.base_app_queue_manager import GenerateTaskStoppedError@@ -540,8 +540,21 @@ class GraphEngine:for var, val in context.items():var.set(val)+ # FIXME(-LAN-): Save current user before entering new app context+ from flask import g++ saved_user = None+ if has_request_context() and hasattr(g, "_login_user"):+ saved_user = g._login_user+with flask_app.app_context():try:+ # Restore user in new app context+ if saved_user is not None:+ from flask import g++ g._login_user = saved_user+q.put(ParallelBranchRunStartedEvent(parallel_id=parallel_id,diff --git a/api/core/workflow/nodes/iteration/iteration_node.py b/api/core/workflow/nodes/iteration/iteration_node.pyindex a061dfc3541..ea0b6863c93 100644--- a/api/core/workflow/nodes/iteration/iteration_node.py+++ b/api/core/workflow/nodes/iteration/iteration_node.py@@ -7,7 +7,7 @@ from datetime import UTC, datetimefrom queue import Empty, Queuefrom typing import TYPE_CHECKING, Any, Optional, cast-from flask import Flask, current_app+from flask import Flask, current_app, has_request_contextfrom configs import dify_configfrom core.variables import ArrayVariable, IntegerVariable, NoneVariable@@ -586,7 +586,21 @@ class IterationNode(BaseNode[IterationNodeData]):"""for var, val in context.items():var.set(val)++ # FIXME(-LAN-): Save current user before entering new app context+ from flask import g++ saved_user = None+ if has_request_context() and hasattr(g, "_login_user"):+ saved_user = g._login_user+with flask_app.app_context():+ # Restore user in new app context+ if saved_user is not None:+ from flask import g++ g._login_user = saved_user+parallel_mode_run_id = uuid.uuid4().hexgraph_engine_copy = graph_engine.create_copy()variable_pool_copy = graph_engine_copy.graph_runtime_state.variable_pool