[PR #28148] Clean up legacy conditions data in if-else nodes to prevent misjudgments #31963

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

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

State: closed
Merged: Yes


Summary

fix #28150

This PR cleans up legacy conditions data handling in if-else workflow nodes and prevents potential runtime errors from stale data references.

Changes Made:

  • Remove deprecated conditions processing: Eliminated all logic that processes the old conditions field in if-else nodes throughout the codebase
  • Clean up variable utilities: Updated getNodeUsedVars, getNodeUsedVarPassToServerKey, and updateNodeVars to only handle the new cases data structure
  • Add migration logic: Implemented automatic data migration in workflow-init.ts to handle any legacy conditions during node initialization
  • Prevent misjudgments: Ensured no code paths accidentally reference non-existent conditions fields

Problem Solved:

Early if-else nodes used conditions + logical_operator fields, but the codebase has migrated to use cases structure. This caused "parameter not found" errors when deleting variables that were referenced in stale/unused conditions fields.

Backward Compatibility:

The migration logic ensures existing workflows continue to work seamlessly without manual intervention.

Files Changed:

  • app/components/workflow/utils/workflow-init.ts - Added migration logic
  • app/components/workflow/nodes/_base/components/variable/utils.ts - Cleaned up variable handling
  • app/components/workflow/nodes/if-else/use-single-run-form-params.ts - Updated form params logic

Testing:

  • Manually verified no runtime errors when handling legacy data
  • Ensured existing workflows remain functional

Screenshots

No UI changes - this is a data structure and logic cleanup.

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/28148 **State:** closed **Merged:** Yes --- ## Summary fix #28150 This PR cleans up legacy `conditions` data handling in if-else workflow nodes and prevents potential runtime errors from stale data references. ### Changes Made: - **Remove deprecated conditions processing**: Eliminated all logic that processes the old `conditions` field in if-else nodes throughout the codebase - **Clean up variable utilities**: Updated `getNodeUsedVars`, `getNodeUsedVarPassToServerKey`, and `updateNodeVars` to only handle the new `cases` data structure - **Add migration logic**: Implemented automatic data migration in `workflow-init.ts` to handle any legacy conditions during node initialization - **Prevent misjudgments**: Ensured no code paths accidentally reference non-existent conditions fields ### Problem Solved: Early if-else nodes used `conditions + logical_operator` fields, but the codebase has migrated to use `cases` structure. This caused "parameter not found" errors when deleting variables that were referenced in stale/unused conditions fields. ### Backward Compatibility: The migration logic ensures existing workflows continue to work seamlessly without manual intervention. ### Files Changed: - `app/components/workflow/utils/workflow-init.ts` - Added migration logic - `app/components/workflow/nodes/_base/components/variable/utils.ts` - Cleaned up variable handling - `app/components/workflow/nodes/if-else/use-single-run-form-params.ts` - Updated form params logic ### Testing: - Manually verified no runtime errors when handling legacy data - Ensured existing workflows remain functional ## Screenshots No UI changes - this is a data structure and logic cleanup. ## 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!) - [ ] 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. - [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:29 -05:00
yindo closed this issue 2026-02-21 20:50:29 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31963