From e9a8a7f8755980848bd5041d6a443c518b99ee18 Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Mon, 10 Mar 2025 14:51:08 +0200 Subject: [PATCH] fix: In addNodeToBeExecuted if stillDataMissing allow more then 2 inputs (#13704) --- cypress/e2e/19-execution.cy.ts | 18 ++ .../merge_node_inputs_paired_items.json | 205 ++++++++++++++++++ .../src/execution-engine/workflow-execute.ts | 10 +- 3 files changed, 228 insertions(+), 5 deletions(-) create mode 100644 cypress/fixtures/merge_node_inputs_paired_items.json diff --git a/cypress/e2e/19-execution.cy.ts b/cypress/e2e/19-execution.cy.ts index 23172f8fda..7de005670f 100644 --- a/cypress/e2e/19-execution.cy.ts +++ b/cypress/e2e/19-execution.cy.ts @@ -597,4 +597,22 @@ describe('Execution', () => { errorToast().should('contain', 'Problem in node ‘Telegram‘'); }); + + it('Paired items should be correctly mapped after passed through the merge node with more than two inputs', () => { + cy.createFixtureWorkflow('merge_node_inputs_paired_items.json'); + + workflowPage.getters.zoomToFitButton().click(); + workflowPage.getters.executeWorkflowButton().click(); + + workflowPage.getters + .canvasNodeByName('Edit Fields') + .within(() => cy.get('.fa-check')) + .should('exist'); + + workflowPage.getters.canvasNodeByName('Edit Fields').dblclick(); + ndv.actions.switchOutputMode('JSON'); + ndv.getters.outputPanel().contains('Branch 1 Value').should('be.visible'); + ndv.getters.outputPanel().contains('Branch 2 Value').should('be.visible'); + ndv.getters.outputPanel().contains('Branch 3 Value').should('be.visible'); + }); }); diff --git a/cypress/fixtures/merge_node_inputs_paired_items.json b/cypress/fixtures/merge_node_inputs_paired_items.json new file mode 100644 index 0000000000..fccbdff943 --- /dev/null +++ b/cypress/fixtures/merge_node_inputs_paired_items.json @@ -0,0 +1,205 @@ +{ + "name": "merge inputs paired items", + "nodes": [ + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "ad1d6260-3c25-49e6-a526-b6a6232d8a61", + "name": "Branch 1 Field", + "value": "Branch 1 Value", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + -220, + 20 + ], + "id": "769d7a98-bc7a-4aa8-9d05-b7c4b7e58d65", + "name": "Branch 1" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "ad1d6260-3c25-49e6-a526-b6a6232d8a61", + "name": "Branch 2 Field", + "value": "Branch 2 Value", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + -220, + 220 + ], + "id": "9a18c73a-5a27-4927-83fa-c3fe442ed7d1", + "name": "Branch 2" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "ad1d6260-3c25-49e6-a526-b6a6232d8a61", + "name": "Branch 3 Field", + "value": "Branch 3 Value", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + -220, + 420 + ], + "id": "3bfa4793-877b-42d3-9b01-10d83a32d26a", + "name": "Branch 3" + }, + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [ + -560, + 220 + ], + "id": "c773e03a-a260-4e02-ae80-6b473ea03398", + "name": "When clicking ‘Test workflow’" + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "8a674ec9-1167-424b-8d99-7878707ab111", + "name": "=item_{{ $itemIndex }}", + "value": "={{ $(`Branch ${$itemIndex + 1}`).item.json[`Branch ${$itemIndex + 1} Field`]}}", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [ + 420, + 220 + ], + "id": "052f4630-5c8f-4847-8288-134e207f0917", + "name": "Edit Fields" + }, + { + "parameters": { + "numberInputs": 3 + }, + "type": "n8n-nodes-base.merge", + "typeVersion": 3, + "position": [ + 200, + 220 + ], + "id": "7bd63947-1a31-44bc-bc04-5e7fd8d3852b", + "name": "Merge V3, dynamic inputs" + } + ], + "pinData": {}, + "connections": { + "Branch 1": { + "main": [ + [ + { + "node": "Merge V3, dynamic inputs", + "type": "main", + "index": 0 + } + ] + ] + }, + "Branch 2": { + "main": [ + [ + { + "node": "Merge V3, dynamic inputs", + "type": "main", + "index": 1 + } + ] + ] + }, + "Branch 3": { + "main": [ + [ + { + "node": "Merge V3, dynamic inputs", + "type": "main", + "index": 2 + } + ] + ] + }, + "When clicking ‘Test workflow’": { + "main": [ + [ + { + "node": "Branch 1", + "type": "main", + "index": 0 + }, + { + "node": "Branch 2", + "type": "main", + "index": 0 + }, + { + "node": "Branch 3", + "type": "main", + "index": 0 + } + ] + ] + }, + "Merge V3, dynamic inputs": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields": { + "main": [ + [] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + }, + "versionId": "4990b19f-2b5f-4095-8ace-12579a08478a", + "meta": { + "templateCredsSetupCompleted": true, + "instanceId": "be251a83c052a9862eeac953816fbb1464f89dfbf79d7ac490a8e336a8cc8bfd" + }, + "id": "9JwaG8aehuYypPc6", + "tags": [] +} \ No newline at end of file diff --git a/packages/core/src/execution-engine/workflow-execute.ts b/packages/core/src/execution-engine/workflow-execute.ts index 55440d50b7..25f2d049c4 100644 --- a/packages/core/src/execution-engine/workflow-execute.ts +++ b/packages/core/src/execution-engine/workflow-execute.ts @@ -909,6 +909,10 @@ export class WorkflowExecute { if (stillDataMissing) { waitingNodeIndex = waitingNodeIndex!; + const waitingExecutionSource = + this.runExecutionData.executionData!.waitingExecutionSource![connectionData.node][ + waitingNodeIndex + ].main; // Additional data is needed to run node so add it to waiting this.prepareWaitingToExecution( @@ -924,11 +928,7 @@ export class WorkflowExecute { this.runExecutionData.executionData!.waitingExecutionSource![connectionData.node][ waitingNodeIndex - ].main[connectionData.index] = { - previousNode: parentNodeName, - previousNodeOutput: outputIndex || undefined, - previousNodeRun: runIndex || undefined, - }; + ].main = waitingExecutionSource; } else { // All data is there so add it directly to stack this.runExecutionData.executionData!.nodeExecutionStack[enqueueFn]({