Merge pull request #5702 from Budibase/fix/pc-fixes-automations

Account for object in failure condition
This commit is contained in:
Peter Clement 2022-05-04 14:05:53 +01:00 committed by GitHub
commit e9bf5b59ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 3 deletions

View File

@ -191,7 +191,6 @@ class Orchestrator {
}
}
}
if (
index === parseInt(env.AUTOMATION_MAX_ITERATIONS) ||
index === loopStep.inputs.iterations
@ -205,10 +204,25 @@ 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
}
if (isFailure) {
this.updateContextAndOutput(loopStepNumber, step, tempOutput, {
status: AutomationErrors.FAILURE_CONDITION,
success: false,