From dea5e73317036143a930624f8a530f18f6c8ec3d Mon Sep 17 00:00:00 2001 From: Peter Clement Date: Wed, 4 May 2022 13:25:46 +0100 Subject: [PATCH] account for objects in failure condition --- packages/server/src/threads/automation.js | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/packages/server/src/threads/automation.js b/packages/server/src/threads/automation.js index 63a3ea8bf3..16a230e263 100644 --- a/packages/server/src/threads/automation.js +++ b/packages/server/src/threads/automation.js @@ -144,6 +144,7 @@ class Orchestrator { (loopStep.inputs.option === "String" && typeof newInput.binding !== "string") ) { + console.log("hello") this.updateContextAndOutput(loopStepNumber, step, tempOutput, { status: AutomationErrors.INCORRECT_TYPE, success: false, @@ -191,7 +192,6 @@ class Orchestrator { } } } - if ( index === parseInt(env.AUTOMATION_MAX_ITERATIONS) || index === loopStep.inputs.iterations @@ -205,10 +205,26 @@ class Orchestrator { break } + let isFailure = false if ( - this._context.steps[loopStepNumber]?.currentItem === - loopStep.inputs.failure + typeof this._context.steps[loopStepNumber]?.currentItem === "object" ) { + isFailure = Object.keys( + this._context.steps[loopStepNumber].currentItem + ).some(value => { + return ( + this._context.steps[loopStepNumber].currentItem[value] === + loopStep.inputs.failure + ) + }) + } else { + isFailure = + this._context.steps[loopStepNumber]?.currentItem === + loopStep.inputs.failure + } + console.log(isFailure) + + if (isFailure) { this.updateContextAndOutput(loopStepNumber, step, tempOutput, { status: AutomationErrors.FAILURE_CONDITION, success: false,