File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
apps/sim/executor/orchestrators Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -84,7 +84,15 @@ export class LoopOrchestrator {
8484
8585 case 'forEach' : {
8686 scope . loopType = 'forEach'
87- if ( ! Array . isArray ( loopConfig . forEachItems ) ) {
87+ // Resolve items first - forEachItems can be a string, reference, array, or object
88+ const items = this . resolveForEachItems ( ctx , loopConfig . forEachItems )
89+
90+ // Check if resolution failed (empty result from non-empty input)
91+ const hasInput =
92+ loopConfig . forEachItems !== undefined &&
93+ loopConfig . forEachItems !== null &&
94+ loopConfig . forEachItems !== ''
95+ if ( hasInput && items . length === 0 ) {
8896 const errorMessage =
8997 'ForEach loop collection is not a valid array. Loop execution blocked.'
9098 logger . error ( errorMessage , { loopId, forEachItems : loopConfig . forEachItems } )
@@ -95,7 +103,6 @@ export class LoopOrchestrator {
95103 scope . condition = buildLoopIndexCondition ( 0 )
96104 break
97105 }
98- const items = this . resolveForEachItems ( ctx , loopConfig . forEachItems )
99106 const originalLength = items . length
100107
101108 if ( originalLength > DEFAULTS . MAX_FOREACH_ITEMS ) {
You can’t perform that action at this time.
0 commit comments