[PR #25442] fix: filter temporary edges from workflow draft sync #31069

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

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

State: closed
Merged: Yes


Bug Fix: Filter temporary edges from workflow draft synchronization

Important

This PR fixes a critical bug where temporary visualization edges were being sent to backend API during workflow synchronization.

close #25454

🐛 Bug Description

Temporary visualization edges created by the node dependency feature were occasionally being sent to the backend API during workflow synchronization, causing invalid source_tmp/target_tmp handle IDs to be persisted in the workflow draft.

Error Information:

  • Invalid handle IDs: source_tmp, target_tmp appearing in backend workflow data
  • Intermittent sync failures when temporary edges are present
  • Potential workflow corruption due to invalid edge data

🔄 Reproduction Steps

  1. Open a workflow in the editor
  2. Select a node to trigger dependency visualization (dimOtherNodes())
  3. Trigger workflow sync (auto-save, manual save, or page close) before the visualization is cleared
  4. Check backend API payload - temporary edges with source_tmp/target_tmp handles are included
  5. Backend receives invalid edge data

Expected Behavior

  • Only actual workflow edges should be sent to backend API
  • Temporary visualization edges should remain client-side only
  • No invalid handle IDs should appear in synchronized data

🔧 Solution

File Changed: app/components/workflow-app/hooks/use-nodes-sync-draft.ts

Line 55 - Before:

const producedEdges = produce(edges, (draft) => {

Line 55 - After:

const producedEdges = produce(edges.filter(edge => !edge.data._isTemp), (draft) => {

🎯 Priority Classification

Problem Type Priority
Core functionality bug (workflow sync, data corruption) High Priority

This is a high priority fix because:

  • Affects core workflow synchronization functionality
  • Can cause data corruption in workflow drafts
  • Impacts backend API with invalid data
  • Intermittent nature makes it hard to debug

Testing

  • Verified temporary edges are filtered out during sync
  • Confirmed normal workflow edges are processed correctly
  • Tested node dependency visualization still works as expected
  • No linting errors introduced
  • Backend no longer receives invalid handle IDs

📸 Screenshots/Evidence

Root Cause Analysis:

  • Temporary edges created in use-nodes-interactions.ts lines 1602, 1619
  • These edges marked with _isTemp: true flag
  • Original sync logic only removed _ prefixed properties but not the edges themselves
  • Race condition between visualization cleanup and workflow sync

Impact: Prevents invalid workflow data from being persisted to backend, ensuring data integrity.> [!IMPORTANT]

**Original Pull Request:** https://github.com/langgenius/dify/pull/25442 **State:** closed **Merged:** Yes --- ### Bug Fix: Filter temporary edges from workflow draft synchronization > [!IMPORTANT] > This PR fixes a critical bug where temporary visualization edges were being sent to backend API during workflow synchronization. close #25454 ## 🐛 Bug Description Temporary visualization edges created by the node dependency feature were occasionally being sent to the backend API during workflow synchronization, causing invalid `source_tmp`/`target_tmp` handle IDs to be persisted in the workflow draft. **Error Information:** - Invalid handle IDs: `source_tmp`, `target_tmp` appearing in backend workflow data - Intermittent sync failures when temporary edges are present - Potential workflow corruption due to invalid edge data ## 🔄 Reproduction Steps 1. Open a workflow in the editor 2. Select a node to trigger dependency visualization (`dimOtherNodes()`) 3. Trigger workflow sync (auto-save, manual save, or page close) before the visualization is cleared 4. Check backend API payload - temporary edges with `source_tmp`/`target_tmp` handles are included 5. Backend receives invalid edge data ## ✅ Expected Behavior - Only actual workflow edges should be sent to backend API - Temporary visualization edges should remain client-side only - No invalid handle IDs should appear in synchronized data ## 🔧 Solution **File Changed:** `app/components/workflow-app/hooks/use-nodes-sync-draft.ts` **Line 55 - Before:** ```typescript const producedEdges = produce(edges, (draft) => { ``` **Line 55 - After:** ```typescript const producedEdges = produce(edges.filter(edge => !edge.data._isTemp), (draft) => { ``` ## 🎯 Priority Classification | Problem Type | Priority | | ------------ | -------- | | Core functionality bug (workflow sync, data corruption) | **High Priority** | This is a **high priority** fix because: - Affects core workflow synchronization functionality - Can cause data corruption in workflow drafts - Impacts backend API with invalid data - Intermittent nature makes it hard to debug ## ✅ Testing - [x] Verified temporary edges are filtered out during sync - [x] Confirmed normal workflow edges are processed correctly - [x] Tested node dependency visualization still works as expected - [x] No linting errors introduced - [x] Backend no longer receives invalid handle IDs ## 📸 Screenshots/Evidence **Root Cause Analysis:** - Temporary edges created in `use-nodes-interactions.ts` lines 1602, 1619 - These edges marked with `_isTemp: true` flag - Original sync logic only removed `_` prefixed properties but not the edges themselves - Race condition between visualization cleanup and workflow sync **Impact:** Prevents invalid workflow data from being persisted to backend, ensuring data integrity.> [!IMPORTANT]
yindo added the pull-request label 2026-02-21 20:48:46 -05:00
yindo closed this issue 2026-02-21 20:48:46 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#31069