From 0f22f3be92db71b6cb37382bc77c86fcd1b9e8de Mon Sep 17 00:00:00 2001 From: Csaba Tuncsik Date: Tue, 2 Sep 2025 15:16:42 +0200 Subject: [PATCH] fix(core): Ensure getNodeOutputs always returns an array (#19069) --- packages/workflow/src/node-helpers.ts | 7 +++++-- packages/workflow/src/workflow.ts | 13 ++++--------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/packages/workflow/src/node-helpers.ts b/packages/workflow/src/node-helpers.ts index 4d0d8fcf64..c12329d7f9 100644 --- a/packages/workflow/src/node-helpers.ts +++ b/packages/workflow/src/node-helpers.ts @@ -1047,12 +1047,15 @@ export function getNodeOutputs( } else { // Calculate the outputs dynamically try { - outputs = (workflow.expression.getSimpleParameterValue( + const result = workflow.expression.getSimpleParameterValue( node, nodeTypeData.outputs, 'internal', {}, - ) || []) as NodeConnectionType[]; + ); + outputs = Array.isArray(result) + ? (result as Array) + : []; } catch (e) { console.warn('Could not calculate outputs dynamically for node: ', node.name); } diff --git a/packages/workflow/src/workflow.ts b/packages/workflow/src/workflow.ts index 49d23070c9..c79cb612cc 100644 --- a/packages/workflow/src/workflow.ts +++ b/packages/workflow/src/workflow.ts @@ -697,15 +697,10 @@ export class Workflow { const outputs = NodeHelpers.getNodeOutputs(this, node, nodeType.description); const nonMainConnectionTypes: NodeConnectionType[] = []; - // Defensive check: NodeHelpers.getNodeOutputs should always return an array, - // but in some edge cases (particularly during testing with incomplete node setup), - // it may return undefined or null - if (Array.isArray(outputs)) { - for (const output of outputs) { - const type = typeof output === 'string' ? output : output.type; - if (type !== NodeConnectionTypes.Main) { - nonMainConnectionTypes.push(type); - } + for (const output of outputs) { + const type = typeof output === 'string' ? output : output.type; + if (type !== NodeConnectionTypes.Main) { + nonMainConnectionTypes.push(type); } }