From 7583e2ad94c5f21df2844446e54d98e7868ba021 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iv=C3=A1n=20Ovejero?= Date: Thu, 9 Jan 2025 11:51:07 +0100 Subject: [PATCH] refactor(core): Report malformed execution data (#12525) --- packages/core/src/WorkflowExecute.ts | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/packages/core/src/WorkflowExecute.ts b/packages/core/src/WorkflowExecute.ts index 3817fe32b2..ffd3b57f50 100644 --- a/packages/core/src/WorkflowExecute.ts +++ b/packages/core/src/WorkflowExecute.ts @@ -1210,7 +1210,27 @@ export class WorkflowExecute { this.status = 'running'; - const startNode = this.runExecutionData.executionData!.nodeExecutionStack[0].node.name; + if (!this.runExecutionData.executionData) { + throw new ApplicationError('Failed to run workflow due to missing execution data', { + extra: { + workflowId: workflow.id, + executionid: this.additionalData.executionId, + mode: this.mode, + }, + }); + } + + const startNode = this.runExecutionData.executionData.nodeExecutionStack.at(0)?.node.name; + + if (!startNode) { + throw new ApplicationError('Failed to run workflow due to empty node execution stack', { + extra: { + workflowId: workflow.id, + executionId: this.additionalData.executionId, + mode: this.mode, + }, + }); + } let destinationNode: string | undefined; if (this.runExecutionData.startData && this.runExecutionData.startData.destinationNode) { @@ -1245,7 +1265,7 @@ export class WorkflowExecute { if (this.runExecutionData.waitTill) { const lastNodeExecuted = this.runExecutionData.resultData.lastNodeExecuted as string; - this.runExecutionData.executionData!.nodeExecutionStack[0].node.disabled = true; + this.runExecutionData.executionData.nodeExecutionStack[0].node.disabled = true; this.runExecutionData.waitTill = undefined; this.runExecutionData.resultData.runData[lastNodeExecuted].pop(); }