@@ -136,17 +136,6 @@ export function normalizeNodeId(nodeId: string): string {
136136 return nodeId
137137}
138138
139- /**
140- * Checks if a value represents valid input (not empty/null/undefined).
141- */
142- export function hasValidInput ( value : any ) : boolean {
143- if ( value === undefined || value === null ) return false
144- if ( typeof value === 'string' ) return value !== ''
145- if ( Array . isArray ( value ) ) return value . length > 0
146- if ( typeof value === 'object' ) return Object . keys ( value ) . length > 0
147- return true
148- }
149-
150139/**
151140 * Validates that a count doesn't exceed a maximum limit.
152141 * Returns an error message if validation fails, undefined otherwise.
@@ -161,6 +150,7 @@ export function validateMaxCount(count: number, max: number, itemType: string):
161150/**
162151 * Resolves array input at runtime. Handles arrays, objects, references, and JSON strings.
163152 * Used by both loop forEach and parallel distribution resolution.
153+ * Throws an error if resolution fails.
164154 */
165155export function resolveArrayInput (
166156 ctx : ExecutionContext ,
@@ -177,14 +167,23 @@ export function resolveArrayInput(
177167
178168 if ( typeof items === 'string' ) {
179169 if ( items . startsWith ( REFERENCE . START ) && items . endsWith ( REFERENCE . END ) && resolver ) {
180- const resolved = resolver . resolveSingleReference ( ctx , '' , items )
181- if ( Array . isArray ( resolved ) ) {
182- return resolved
170+ try {
171+ const resolved = resolver . resolveSingleReference ( ctx , '' , items )
172+ if ( Array . isArray ( resolved ) ) {
173+ return resolved
174+ }
175+ if ( typeof resolved === 'object' && resolved !== null ) {
176+ return Object . entries ( resolved )
177+ }
178+ throw new Error ( `Reference "${ items } " did not resolve to an array or object` )
179+ } catch ( error ) {
180+ if ( error instanceof Error && error . message . startsWith ( 'Reference "' ) ) {
181+ throw error
182+ }
183+ throw new Error (
184+ `Failed to resolve reference "${ items } ": ${ error instanceof Error ? error . message : String ( error ) } `
185+ )
183186 }
184- if ( typeof resolved === 'object' && resolved !== null ) {
185- return Object . entries ( resolved )
186- }
187- return [ ]
188187 }
189188
190189 try {
@@ -196,9 +195,12 @@ export function resolveArrayInput(
196195 if ( typeof parsed === 'object' && parsed !== null ) {
197196 return Object . entries ( parsed )
198197 }
199- return [ ]
200- } catch {
201- return [ ]
198+ throw new Error ( `Parsed value is not an array or object` )
199+ } catch ( error ) {
200+ if ( error instanceof Error && error . message . startsWith ( 'Parsed value' ) ) {
201+ throw error
202+ }
203+ throw new Error ( `Failed to parse items as JSON: "${ items } "` )
202204 }
203205 }
204206
@@ -208,9 +210,14 @@ export function resolveArrayInput(
208210 if ( Array . isArray ( resolved ) ) {
209211 return resolved
210212 }
211- return [ ]
212- } catch {
213- return [ ]
213+ throw new Error ( `Resolved items is not an array` )
214+ } catch ( error ) {
215+ if ( error instanceof Error && error . message . startsWith ( 'Resolved items' ) ) {
216+ throw error
217+ }
218+ throw new Error (
219+ `Failed to resolve items: ${ error instanceof Error ? error . message : String ( error ) } `
220+ )
214221 }
215222 }
216223
0 commit comments