Connection and variables are lost when block changes are made #7324

Closed
opened 2026-02-21 18:20:00 -05:00 by yindo · 4 comments
Owner

Originally created by @sotono-046 on GitHub (Dec 20, 2024).

Self Checks

  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report (我已阅读并同意 Language Policy).
  • [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

0.14.1

Cloud or Self Hosted

Cloud

Steps to reproduce

  • Create a new block, any type is acceptable
  • Set variables in the block and make it have connections to other blocks
  • Select “Change Block” from the context menu
  • The existing block is replaced by the new block of your choice.
  • The variables set in the existing block and its connections to other blocks will be deleted.

✔️ Expected Behavior

  • Preserves the connection between the variable and the block when the block is changed
  • If variables are difficult, keep the connection
  • (If it is not compatible, there should be no connection)

Actual Behavior

  • The variables set in the existing block and its connections to other blocks will be deleted.
Originally created by @sotono-046 on GitHub (Dec 20, 2024). ### Self Checks - [X] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [X] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [X] I confirm that I am using English to submit this report (我已阅读并同意 [Language Policy](https://github.com/langgenius/dify/issues/1542)). - [X] [FOR CHINESE USERS] 请务必使用英文提交 Issue,否则会被关闭。谢谢!:) - [X] Please do not modify this template :) and fill in all the required fields. ### Dify version 0.14.1 ### Cloud or Self Hosted Cloud ### Steps to reproduce - Create a new block, any type is acceptable - Set variables in the block and make it have connections to other blocks - Select “Change Block” from the context menu - The existing block is replaced by the new block of your choice. - The variables set in the existing block and its connections to other blocks will be deleted. ### ✔️ Expected Behavior - Preserves the connection between the variable and the block when the block is changed - If variables are difficult, keep the connection - (If it is not compatible, there should be no connection) ### ❌ Actual Behavior - The variables set in the existing block and its connections to other blocks will be deleted.
yindo added the 💪 enhancement label 2026-02-21 18:20:00 -05:00
yindo closed this issue 2026-02-21 18:20:00 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Dec 20, 2024):

Hello @sotono-046! 👋 I'm here to help you with bugs, questions, and becoming a contributor. I'm Dosu, a bot designed to assist you while you wait for a human maintainer.

The issue you're experiencing, where connections and variables are lost when a block is changed, seems to be related to how Dify handles block changes. Currently, there isn't specific documentation or code comments in the Dify codebase that explain the rationale behind deleting connections when a block is changed. However, the logic for handling variable preservation when a block is changed involves checking for affected nodes and updating them if a variable's name changes [1].

To address this issue, you might consider implementing a mechanism that checks for compatibility between the old and new block types before deciding whether to preserve or delete connections and variables. This could involve:

  1. Compatibility Check: Before changing a block, check if the new block type is compatible with the existing connections and variables. If compatible, preserve them.

  2. Preservation Logic: Implement logic to update the connections and variables to fit the new block type, if possible.

  3. User Confirmation: If compatibility cannot be ensured, prompt the user to confirm the deletion of connections and variables.

These steps could help in maintaining the integrity of your workflow when blocks are changed.

To continue talking to Dosu, mention @dosu.


Help Dosu learn! Give it feedback: Great Response | Irrelevant Answer | Incorrect Sources | Too Verbose | Hallucination | Other

@dosubot[bot] commented on GitHub (Dec 20, 2024): <!-- Greeting --> Hello @sotono-046! 👋 I'm here to help you with bugs, questions, and becoming a contributor. I'm Dosu, a bot designed to assist you while you wait for a human maintainer. <!-- Answer --> The issue you're experiencing, where connections and variables are lost when a block is changed, seems to be related to how Dify handles block changes. Currently, there isn't specific documentation or code comments in the Dify codebase that explain the rationale behind deleting connections when a block is changed. However, the logic for handling variable preservation when a block is changed involves checking for affected nodes and updating them if a variable's name changes <sup>[[1]](https://github.com/langgenius/dify/blob/main/web/app/components/workflow/panel/chat-variable-panel/index.tsx)</sup>. To address this issue, you might consider implementing a mechanism that checks for compatibility between the old and new block types before deciding whether to preserve or delete connections and variables. This could involve: 1. **Compatibility Check**: Before changing a block, check if the new block type is compatible with the existing connections and variables. If compatible, preserve them. 2. **Preservation Logic**: Implement logic to update the connections and variables to fit the new block type, if possible. 3. **User Confirmation**: If compatibility cannot be ensured, prompt the user to confirm the deletion of connections and variables. These steps could help in maintaining the integrity of your workflow when blocks are changed. <!-- Dosu Comment Footer --> *To continue talking to [Dosu](https://dosu.dev), mention @dosu.* --- <sup>Help Dosu learn! Give it feedback: [Great Response](https://app.dosu.dev/response-feedback/e0e5757d-8ca1-4214-bb35-2e0bd651bd28?feedback_type=great_response) | [Irrelevant Answer](https://app.dosu.dev/response-feedback/e0e5757d-8ca1-4214-bb35-2e0bd651bd28?feedback_type=irrelevant_answer) | [Incorrect Sources](https://app.dosu.dev/response-feedback/e0e5757d-8ca1-4214-bb35-2e0bd651bd28?feedback_type=incorrect_sources) | [Too Verbose](https://app.dosu.dev/response-feedback/e0e5757d-8ca1-4214-bb35-2e0bd651bd28?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e0e5757d-8ca1-4214-bb35-2e0bd651bd28?feedback_type=hallucination) | [Other](https://app.dosu.dev/response-feedback/e0e5757d-8ca1-4214-bb35-2e0bd651bd28?feedback_type=other)</sup>
Author
Owner

@sotono-046 commented on GitHub (Dec 20, 2024):

Sorry, I checked but forgot to attach the recording of the actual behavior, here it is!

https://github.com/user-attachments/assets/3075223e-e611-4979-a813-15659ca2ce88

@sotono-046 commented on GitHub (Dec 20, 2024): Sorry, I checked but forgot to attach the recording of the actual behavior, here it is! https://github.com/user-attachments/assets/3075223e-e611-4979-a813-15659ca2ce88
Author
Owner

@crazywoola commented on GitHub (Dec 20, 2024):

Preserves the connection between the variable and the block when the block is changed
If variables are difficult, keep the connection
(If it is not compatible, there should be no connection)

I think we decided to do this because the 3 items is too complicated to achieve.

The variables set in the existing block and its connections to other blocks will be deleted.

@crazywoola commented on GitHub (Dec 20, 2024): > Preserves the connection between the variable and the block when the block is changed > If variables are difficult, keep the connection > (If it is not compatible, there should be no connection) I think we decided to do this because the 3 items is too complicated to achieve. > The variables set in the existing block and its connections to other blocks will be deleted.
Author
Owner

@dosubot[bot] commented on GitHub (Jan 21, 2025):

Hi, @sotono-046. I'm Dosu, and I'm helping the Dify team manage their backlog. I'm marking this issue as stale.

Issue Summary:

  • You reported a bug in Dify version 0.14.1 where changing a block results in the loss of variables and connections.
  • I suggested adding compatibility checks or user prompts to preserve connections.
  • You provided a recording of the issue for clarity.
  • Crazywoola mentioned that preserving connections was considered too complex, leading to the current behavior.

Next Steps:

  • Please let us know if this issue is still relevant to the latest version of Dify by commenting here.
  • If there is no further activity, this issue will be automatically closed in 15 days.

Thank you for your understanding and contribution!

@dosubot[bot] commented on GitHub (Jan 21, 2025): Hi, @sotono-046. I'm [Dosu](https://dosu.dev), and I'm helping the Dify team manage their backlog. I'm marking this issue as stale. **Issue Summary:** - You reported a bug in Dify version 0.14.1 where changing a block results in the loss of variables and connections. - I suggested adding compatibility checks or user prompts to preserve connections. - You provided a recording of the issue for clarity. - Crazywoola mentioned that preserving connections was considered too complex, leading to the current behavior. **Next Steps:** - Please let us know if this issue is still relevant to the latest version of Dify by commenting here. - If there is no further activity, this issue will be automatically closed in 15 days. Thank you for your understanding and contribution!
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#7324