Variable Assigner inside loop cannot reference loop variable, causing 'Variable not found' error (v1.16.0) #39869
Replies: 2 comments
|
@caomuyunshui, this looks like a snippet variable remapping bug. Here's what I found: Root cause: When a snippet is inserted into a workflow, all node IDs are regenerated and variable references are remapped via This explains why manually building the same workflow works — the IDs are consistent when you create it by hand, but snippet insertion breaks the reference. This is a known gap. PR #39843 recently fixed snippet variable remapping for many node types but did not cover the v2 Variable Assigner Workaround: After inserting the snippet, open the Variable Assigner node inside the Loop, clear its variable reference, and re-select the loop variable from the picker. This will re-establish the reference with the correct (new) loop node ID. There's also a potentially related older issue (#38246) where Variable Assigner nodes inside Loops could be missing To reply, just mention @dosu. Share context across your team and agents. Try Dosu. |
|
An independent minimal snippet reproduces the stale-reference failure during insertion: Dify regenerates node IDs, but |
Uh oh!
There was an error while loading. Please reload this page.
Self Checks
Content
Dify version
1.16.0Steps to Reproduce
iiwith an initial value offalse.ii) to a new value (e.g.,true).✔️ Expected Behavior
According to the official Dify documentation, Variable Assigner nodes support assigning values to loop variables. The Variable Assigner node inside the loop should be able to reference and update the loop variable (
ii) without any errors. The workflow should run successfully and exit the loop when the termination condition is met.❌ Actual Behavior
The workflow execution fails with a
Variable not founderror for the loop variableii. The Variable Assigner node cannot resolve the reference to the loop variable, even though it is defined in the parent Loop node.Note: A manually built workflow (via drag-and-drop) with the same logic works correctly. The issue appears to be specifically triggered when the workflow is imported or parsed as a
snippet, where the internal variable references (especially absolute paths like['<loop_node_id>', 'ii']) are not correctly re-established.Error Log
带变量赋值.yml
启动Word服务-不带变量赋值.yml
All reactions