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: dataset query created_by empty UUID in iteration subgraph (#34004) (#34044)
Achieve33185341cd015b62
diff --git a/api/core/app/apps/advanced_chat/app_runner.py b/api/core/app/apps/advanced_chat/app_runner.pyindex 1ff2bbc914f..d21fce144eb 100644--- a/api/core/app/apps/advanced_chat/app_runner.py+++ b/api/core/app/apps/advanced_chat/app_runner.py@@ -137,6 +137,7 @@ class AdvancedChatAppRunner(WorkflowBasedAppRunner):workflow=self._workflow,single_iteration_run=self.application_generate_entity.single_iteration_run,single_loop_run=self.application_generate_entity.single_loop_run,+ user_id=self.application_generate_entity.user_id,)else:inputs = self.application_generate_entity.inputsdiff --git a/api/core/app/apps/pipeline/pipeline_runner.py b/api/core/app/apps/pipeline/pipeline_runner.pyindex 9a5107f8318..44d2450f743 100644--- a/api/core/app/apps/pipeline/pipeline_runner.py+++ b/api/core/app/apps/pipeline/pipeline_runner.py@@ -106,6 +106,7 @@ class PipelineRunner(WorkflowBasedAppRunner):workflow=workflow,single_iteration_run=self.application_generate_entity.single_iteration_run,single_loop_run=self.application_generate_entity.single_loop_run,+ user_id=self.application_generate_entity.user_id,)else:inputs = self.application_generate_entity.inputsdiff --git a/api/core/app/apps/workflow/app_runner.py b/api/core/app/apps/workflow/app_runner.pyindex 0b058eefce9..c02c0b16e94 100644--- a/api/core/app/apps/workflow/app_runner.py+++ b/api/core/app/apps/workflow/app_runner.py@@ -92,6 +92,7 @@ class WorkflowAppRunner(WorkflowBasedAppRunner):workflow=self._workflow,single_iteration_run=self.application_generate_entity.single_iteration_run,single_loop_run=self.application_generate_entity.single_loop_run,+ user_id=self.application_generate_entity.user_id,)else:inputs = self.application_generate_entity.inputsdiff --git a/api/core/app/apps/workflow_app_runner.py b/api/core/app/apps/workflow_app_runner.pyindex e99372b058a..d7d3bd27de4 100644--- a/api/core/app/apps/workflow_app_runner.py+++ b/api/core/app/apps/workflow_app_runner.py@@ -164,6 +164,8 @@ class WorkflowBasedAppRunner:workflow: Workflow,single_iteration_run: Any | None = None,single_loop_run: Any | None = None,+ *,+ user_id: str,) -> tuple[Graph, VariablePool, GraphRuntimeState]:"""Prepare graph, variable pool, and runtime state for single node execution@@ -200,6 +202,7 @@ class WorkflowBasedAppRunner:graph_runtime_state=graph_runtime_state,node_type_filter_key="iteration_id",node_type_label="iteration",+ user_id=user_id,)elif single_loop_run:graph, variable_pool = self._get_graph_and_variable_pool_for_single_node_run(@@ -209,6 +212,7 @@ class WorkflowBasedAppRunner:graph_runtime_state=graph_runtime_state,node_type_filter_key="loop_id",node_type_label="loop",+ user_id=user_id,)else:raise ValueError("Neither single_iteration_run nor single_loop_run is specified")@@ -225,6 +229,8 @@ class WorkflowBasedAppRunner:graph_runtime_state: GraphRuntimeState,node_type_filter_key: str, # 'iteration_id' or 'loop_id'node_type_label: str = "node", # 'iteration' or 'loop' for error messages+ *,+ user_id: str = "",) -> tuple[Graph, VariablePool]:"""Get graph and variable pool for single node execution (iteration or loop).@@ -290,7 +296,7 @@ class WorkflowBasedAppRunner:run_context=build_dify_run_context(tenant_id=workflow.tenant_id,app_id=self._app_id,- user_id="",+ user_id=user_id,user_from=UserFrom.ACCOUNT,invoke_from=InvokeFrom.DEBUGGER,),diff --git a/api/core/rag/retrieval/dataset_retrieval.py b/api/core/rag/retrieval/dataset_retrieval.pyindex 66a0bee9199..49b91707ec0 100644--- a/api/core/rag/retrieval/dataset_retrieval.py+++ b/api/core/rag/retrieval/dataset_retrieval.py@@ -71,6 +71,7 @@ from graphon.model_runtime.entities.llm_entities import LLMMode, LLMResult, LLMUfrom graphon.model_runtime.entities.message_entities import PromptMessage, PromptMessageRole, PromptMessageToolfrom graphon.model_runtime.entities.model_entities import ModelFeature, ModelTypefrom graphon.model_runtime.model_providers.__base.large_language_model import LargeLanguageModel+from libs.helper import parse_uuid_str_or_nonefrom libs.json_in_md_parser import parse_and_check_json_markdownfrom models import UploadFilefrom models.dataset import (@@ -1024,8 +1025,13 @@ class DatasetRetrieval:"""if not query and not attachment_ids:return- created_by_role = self._resolve_creator_user_role(user_from)- if created_by_role is None:+ created_by = parse_uuid_str_or_none(user_id)+ if created_by is None:+ logger.debug(+ "Skipping dataset query log: empty created_by user_id (user_from=%s, app_id=%s)",+ user_from,+ app_id,+ )returndataset_queries = []for dataset_id in dataset_ids:@@ -1041,8 +1047,8 @@ class DatasetRetrieval:content=json.dumps(contents),source=DatasetQuerySource.APP,source_app_id=app_id,- created_by_role=created_by_role,- created_by=user_id,+ created_by_role=CreatorUserRole(user_from),+ created_by=created_by,)dataset_queries.append(dataset_query)if dataset_queries:diff --git a/api/libs/helper.py b/api/libs/helper.pyindex 18bc869f31e..b1815859a54 100644--- a/api/libs/helper.py+++ b/api/libs/helper.py@@ -174,6 +174,18 @@ def normalize_uuid(value: str | UUID) -> str:raise ValueError("must be a valid UUID") from exc+def parse_uuid_str_or_none(value: str | None) -> str | None:+ """+ Return None for missing/empty UUID-like values.++ Keep non-empty values unchanged to avoid changing behavior in paths that+ currently pass placeholder IDs in tests/mocks.+ """+ if value is None or not str(value).strip():+ return None+ return str(value)++UUIDStrOrEmpty = Annotated[str, AfterValidator(normalize_uuid)]diff --git a/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_core.py b/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_core.pyindex f43d6a04151..58c7bfa4bc2 100644--- a/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_core.py+++ b/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_core.py@@ -88,7 +88,7 @@ class TestWorkflowBasedAppRunner:workflow = SimpleNamespace(environment_variables=[], graph_dict={})with pytest.raises(ValueError, match="Neither single_iteration_run nor single_loop_run"):- runner._prepare_single_node_execution(workflow, None, None)+ runner._prepare_single_node_execution(workflow, None, None, user_id="00000000-0000-0000-0000-000000000001")def test_get_graph_and_variable_pool_for_single_node_run(self, monkeypatch):runner = WorkflowBasedAppRunner(queue_manager=SimpleNamespace(), app_id="app")@@ -136,6 +136,7 @@ class TestWorkflowBasedAppRunner:graph_runtime_state=graph_runtime_state,node_type_filter_key="iteration_id",node_type_label="iteration",+ user_id="00000000-0000-0000-0000-000000000001",)assert graph is not Nonediff --git a/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_single_node.py b/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_single_node.pyindex a11ee156f87..620a153204d 100644--- a/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_single_node.py+++ b/api/tests/unit_tests/core/app/apps/test_workflow_app_runner_single_node.py@@ -100,6 +100,7 @@ def test_run_uses_single_node_execution_branch(workflow=workflow,single_iteration_run=single_iteration_run,single_loop_run=single_loop_run,+ user_id="user",)init_graph.assert_not_called()@@ -158,6 +159,7 @@ def test_single_node_run_validates_target_node_config(monkeypatch) -> None:graph_runtime_state=graph_runtime_state,node_type_filter_key="loop_id",node_type_label="loop",+ user_id="00000000-0000-0000-0000-000000000001",)assert seen_configs == [workflow.graph_dict["nodes"][0]]