[PR #28867] fix: Variable Assigner node silently fails for legacy V1 data format #32212

Closed
opened 2026-02-21 20:50:58 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/langgenius/dify/pull/28867

State: closed
Merged: Yes


Summary

Fixes #28862

Problem

The DifyNodeFactory.create_node() method always used LATEST_VERSION to instantiate node classes, ignoring the version field in node data. This caused backward compatibility issues for nodes with multiple versions (e.g., VARIABLE_ASSIGNER).

When legacy V1 format workflow data (without version field) was processed by VariableAssignerNodeV2, the node execution would silently fail - reporting success while performing no actual operations. This is because V1 data lacks the items array that V2 expects, and V2's items field defaults to an empty list.

Solution

Modified node_factory.py to select the appropriate node class version based on the version field in node data:

latest_node_class = node_mapping.get(LATEST_VERSION)
matched_node_class = node_mapping.get(node_data.get("version", "1"))
node_class = matched_node_class or latest_node_class

This change:

  1. Defaults to version "1" for legacy data without a version field (backward compatibility)
  2. Uses the matched version class if available in the mapping
  3. Falls back to LATEST_VERSION if the specified version is not found

Impact

  • VARIABLE_ASSIGNER nodes: Legacy V1 workflows will now correctly use VariableAssignerNodeV1 instead of silently failing with VariableAssignerNodeV2
  • Future-proof: Any node type with multiple versions will benefit from proper version routing
  • No breaking changes: Existing V2 workflows continue to work as expected

Screenshots

Before After
image image

Checklist

  • This change requires a documentation update, included: Dify Document
  • I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!)
  • I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change.
  • I've updated the documentation accordingly.
  • I ran dev/reformat(backend) and cd web && npx lint-staged(frontend) to appease the lint gods
**Original Pull Request:** https://github.com/langgenius/dify/pull/28867 **State:** closed **Merged:** Yes --- ## Summary Fixes #28862 ### Problem The `DifyNodeFactory.create_node()` method always used `LATEST_VERSION` to instantiate node classes, ignoring the `version` field in node data. This caused backward compatibility issues for nodes with multiple versions (e.g., `VARIABLE_ASSIGNER`). When legacy V1 format workflow data (without `version` field) was processed by `VariableAssignerNodeV2`, the node execution would silently fail - reporting success while performing no actual operations. This is because V1 data lacks the `items` array that V2 expects, and V2's `items` field defaults to an empty list. ### Solution Modified `node_factory.py` to select the appropriate node class version based on the `version` field in node data: ```python latest_node_class = node_mapping.get(LATEST_VERSION) matched_node_class = node_mapping.get(node_data.get("version", "1")) node_class = matched_node_class or latest_node_class ``` This change: 1. Defaults to version `"1"` for legacy data without a `version` field (backward compatibility) 2. Uses the matched version class if available in the mapping 3. Falls back to `LATEST_VERSION` if the specified version is not found ### Impact - **VARIABLE_ASSIGNER nodes**: Legacy V1 workflows will now correctly use `VariableAssignerNodeV1` instead of silently failing with `VariableAssignerNodeV2` - **Future-proof**: Any node type with multiple versions will benefit from proper version routing - **No breaking changes**: Existing V2 workflows continue to work as expected ## Screenshots | Before | After | |--------|-------| | <img width="2880" height="1624" alt="image" src="https://github.com/user-attachments/assets/b4e95eda-b94c-465b-b7c2-69c0b58152f1" />| <img width="2880" height="1624" alt="image" src="https://github.com/user-attachments/assets/f73cfab6-85cb-4181-9585-1912df61848b" />| ## Checklist - [ ] This change requires a documentation update, included: [Dify Document](https://github.com/langgenius/dify-docs) - [x] I understand that this PR may be closed in case there was no previous discussion or issues. (This doesn't apply to typos!) - [x] I've added a test for each change that was introduced, and I tried as much as possible to make a single atomic change. - [x] I've updated the documentation accordingly. - [x] I ran `dev/reformat`(backend) and `cd web && npx lint-staged`(frontend) to appease the lint gods
yindo added the pull-request label 2026-02-21 20:50:58 -05:00
yindo closed this issue 2026-02-21 20:50:58 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#32212