diff --git a/packages/core/src/execution-engine/__tests__/workflows/always_output_data_multiple_outputs.json b/packages/core/src/execution-engine/__tests__/workflows/always_output_data_multiple_outputs.json new file mode 100644 index 0000000000..c68c42aecf --- /dev/null +++ b/packages/core/src/execution-engine/__tests__/workflows/always_output_data_multiple_outputs.json @@ -0,0 +1,137 @@ +{ + "name": "Always Output Data Multiple Outputs", + "nodes": [ + { + "parameters": {}, + "type": "n8n-nodes-base.manualTrigger", + "typeVersion": 1, + "position": [0, 0], + "id": "b7c1c0d1-ff36-4899-8f95-4405bbbcfad0", + "name": "When clicking ‘Execute workflow’" + }, + { + "parameters": { + "conditions": { + "options": { + "caseSensitive": true, + "leftValue": "", + "typeValidation": "strict", + "version": 2 + }, + "conditions": [ + { + "id": "8bc8b97d-2d13-4267-80e4-5947cb0c61db", + "leftValue": false, + "rightValue": "", + "operator": { + "type": "boolean", + "operation": "true", + "singleValue": true + } + } + ], + "combinator": "and" + }, + "options": {} + }, + "type": "n8n-nodes-base.if", + "typeVersion": 2.2, + "position": [448, 0], + "id": "8d02b70d-d24f-4f38-ad68-588ef3479d3e", + "name": "If", + "alwaysOutputData": true + }, + { + "parameters": { + "assignments": { + "assignments": [ + { + "id": "40ee7f65-691d-40e8-99cc-ccdc0632319e", + "name": "foo", + "value": "bar", + "type": "string" + } + ] + }, + "options": {} + }, + "type": "n8n-nodes-base.set", + "typeVersion": 3.4, + "position": [224, 0], + "id": "41e24bec-18b6-4d73-9737-98294117a41a", + "name": "Edit Fields" + }, + { + "parameters": {}, + "type": "n8n-nodes-base.noOp", + "typeVersion": 1, + "position": [704, 0], + "id": "1ce47245-adc0-4352-8435-ab6b563ce76f", + "name": "No Operation, do nothing" + } + ], + "pinData": { + "No Operation, do nothing": [ + { + "json": { + "foo": "bar" + }, + "pairedItem": { + "item": 0 + } + } + ] + }, + "connections": { + "When clicking ‘Execute workflow’": { + "main": [ + [ + { + "node": "Edit Fields", + "type": "main", + "index": 0 + } + ] + ] + }, + "Edit Fields": { + "main": [ + [ + { + "node": "If", + "type": "main", + "index": 0 + } + ] + ] + }, + "If": { + "main": [ + [ + { + "node": "No Operation, do nothing", + "type": "main", + "index": 0 + } + ], + [ + { + "node": "No Operation, do nothing", + "type": "main", + "index": 0 + } + ] + ] + } + }, + "active": false, + "settings": { + "executionOrder": "v1" + }, + "versionId": "a60cd1b6-d52d-408c-9cc0-dd91c1477ee1", + "meta": { + "instanceId": "eeda9e3069aca300d1dfceeb64beb5b53d715db44a50461bbc5cb0cf6daa01e3" + }, + "id": "25lWZUaSQnoiwP7h", + "tags": [] +} diff --git a/packages/core/src/execution-engine/__tests__/workflows/paired_items_fix.json b/packages/core/src/execution-engine/__tests__/workflows/paired_items_fix.json index dbd036f70c..863c65471d 100644 --- a/packages/core/src/execution-engine/__tests__/workflows/paired_items_fix.json +++ b/packages/core/src/execution-engine/__tests__/workflows/paired_items_fix.json @@ -21,17 +21,11 @@ }, { "parameters": { - "conditions": { - "boolean": [ - { - "value1": true - } - ] - } + "jsCode": "return []" }, - "id": "4d4af5e5-860d-416f-b2d7-f0f87f380355", - "name": "IF", - "type": "n8n-nodes-base.if", + "id": "58198a44-6b5c-4ad1-a03b-8b9e319b6c1b", + "name": "Return no items", + "type": "n8n-nodes-base.code", "typeVersion": 1, "position": [1080, 500], "alwaysOutputData": true @@ -415,17 +409,6 @@ ] ] }, - "IF": { - "main": [ - [ - { - "node": "Set1", - "type": "main", - "index": 0 - } - ] - ] - }, "When clicking \"Execute Workflow\"": { "main": [ [ @@ -446,7 +429,7 @@ "main": [ [ { - "node": "IF", + "node": "Return no items", "type": "main", "index": 0 } @@ -552,6 +535,17 @@ } ] ] + }, + "Return no items": { + "main": [ + [ + { + "node": "Set1", + "type": "main", + "index": 0 + } + ] + ] } }, "active": false, diff --git a/packages/core/src/execution-engine/workflow-execute.ts b/packages/core/src/execution-engine/workflow-execute.ts index 3fa64592ea..6dd68bccb5 100644 --- a/packages/core/src/execution-engine/workflow-execute.ts +++ b/packages/core/src/execution-engine/workflow-execute.ts @@ -1632,8 +1632,10 @@ export class WorkflowExecute { }); nodeSuccessData = this.assignPairedItems(nodeSuccessData, executionData); + const noOutputData = + !nodeSuccessData || nodeSuccessData.every((data) => !data?.length); - if (!nodeSuccessData?.[0]?.[0]) { + if (noOutputData) { if (executionData.node.alwaysOutputData === true) { const pairedItem: IPairedItemData[] = [];