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: Variable Assigner node silently fails for legacy V1 data format (#28867)

kinglisky02fdc5e2a47c
diff --git a/api/core/workflow/nodes/node_factory.py b/api/core/workflow/nodes/node_factory.py
index 5fc363257bb..c55ad346bf0 100644
--- a/api/core/workflow/nodes/node_factory.py
+++ b/api/core/workflow/nodes/node_factory.py
@@ -64,7 +64,10 @@ class DifyNodeFactory(NodeFactory):
if not node_mapping:
raise ValueError(f"No class mapping found for node type: {node_type}")
- node_class = node_mapping.get(LATEST_VERSION)
+ latest_node_class = node_mapping.get(LATEST_VERSION)
+ node_version = str(node_data.get("version", "1"))
+ matched_node_class = node_mapping.get(node_version)
+ node_class = matched_node_class or latest_node_class
if not node_class:
raise ValueError(f"No latest version class found for node type: {node_type}")
diff --git a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py
index ef23a8f565f..c62fc4d8fe2 100644
--- a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py
+++ b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v1/test_variable_assigner_v1.py
@@ -30,7 +30,13 @@ def test_overwrite_string_variable():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "version": "1", "title": "Variable Assigner", "items": []},
+ "data": {
+ "type": "assigner",
+ "title": "Variable Assigner",
+ "assigned_variable_selector": ["conversation", "test_conversation_variable"],
+ "write_mode": "over-write",
+ "input_variable_selector": ["node_id", "test_string_variable"],
+ },
"id": "assigner",
},
],
@@ -131,7 +137,13 @@ def test_append_variable_to_array():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "version": "1", "title": "Variable Assigner", "items": []},
+ "data": {
+ "type": "assigner",
+ "title": "Variable Assigner",
+ "assigned_variable_selector": ["conversation", "test_conversation_variable"],
+ "write_mode": "append",
+ "input_variable_selector": ["node_id", "test_string_variable"],
+ },
"id": "assigner",
},
],
@@ -231,7 +243,13 @@ def test_clear_array():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "version": "1", "title": "Variable Assigner", "items": []},
+ "data": {
+ "type": "assigner",
+ "title": "Variable Assigner",
+ "assigned_variable_selector": ["conversation", "test_conversation_variable"],
+ "write_mode": "clear",
+ "input_variable_selector": [],
+ },
"id": "assigner",
},
],
diff --git a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py
index f793341e734..caa36734adb 100644
--- a/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py
+++ b/api/tests/unit_tests/core/workflow/nodes/variable_assigner/v2/test_variable_assigner_v2.py
@@ -78,7 +78,7 @@ def test_remove_first_from_array():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "title": "Variable Assigner", "items": []},
+ "data": {"type": "assigner", "version": "2", "title": "Variable Assigner", "items": []},
"id": "assigner",
},
],
@@ -162,7 +162,7 @@ def test_remove_last_from_array():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "title": "Variable Assigner", "items": []},
+ "data": {"type": "assigner", "version": "2", "title": "Variable Assigner", "items": []},
"id": "assigner",
},
],
@@ -243,7 +243,7 @@ def test_remove_first_from_empty_array():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "title": "Variable Assigner", "items": []},
+ "data": {"type": "assigner", "version": "2", "title": "Variable Assigner", "items": []},
"id": "assigner",
},
],
@@ -324,7 +324,7 @@ def test_remove_last_from_empty_array():
"nodes": [
{"data": {"type": "start", "title": "Start"}, "id": "start"},
{
- "data": {"type": "assigner", "title": "Variable Assigner", "items": []},
+ "data": {"type": "assigner", "version": "2", "title": "Variable Assigner", "items": []},
"id": "assigner",
},
],