diff --git a/packages/server/src/threads/automation.ts b/packages/server/src/threads/automation.ts index 6ed8506b85..9831a96936 100644 --- a/packages/server/src/threads/automation.ts +++ b/packages/server/src/threads/automation.ts @@ -44,10 +44,18 @@ function getLoopIterations(loopStep: LoopStep) { if (!binding) { return 0 } + const isString = typeof binding === "string" + try { + if (isString) { + binding = JSON.parse(binding) + } + } catch (err) { + // ignore error - wasn't able to parse + } if (Array.isArray(binding)) { return binding.length } - if (typeof binding === "string") { + if (isString) { return automationUtils.stringSplit(binding).length } return 0