@@ -11,24 +11,18 @@ import {
1111} from '@/executor/variables/resolvers/reference'
1212import type { SerializedBlock , SerializedWorkflow } from '@/serializer/types'
1313
14- /**
15- * Check if a path exists in an output schema.
16- * Handles nested objects, arrays, and various schema formats.
17- * Numeric indices (array access) are skipped during validation.
18- */
1914function isPathInOutputSchema (
2015 outputs : Record < string , any > | undefined ,
2116 pathParts : string [ ]
2217) : boolean {
2318 if ( ! outputs || pathParts . length === 0 ) {
24- return true // No schema or no path = allow (lenient)
19+ return true
2520 }
2621
2722 let current : any = outputs
2823 for ( let i = 0 ; i < pathParts . length ; i ++ ) {
2924 const part = pathParts [ i ]
3025
31- // Skip numeric indices (array access like items.0.name)
3226 if ( / ^ \d + $ / . test ( part ) ) {
3327 continue
3428 }
@@ -37,21 +31,17 @@ function isPathInOutputSchema(
3731 return false
3832 }
3933
40- // Check if the key exists directly
4134 if ( part in current ) {
4235 current = current [ part ]
4336 continue
4437 }
4538
46- // Check if current has 'properties' (object type with nested schema)
4739 if ( current . properties && part in current . properties ) {
4840 current = current . properties [ part ]
4941 continue
5042 }
5143
52- // Check if current is an array type with items
5344 if ( current . type === 'array' && current . items ) {
54- // Array items can have properties or be a nested schema
5545 if ( current . items . properties && part in current . items . properties ) {
5646 current = current . items . properties [ part ]
5747 continue
@@ -62,25 +52,18 @@ function isPathInOutputSchema(
6252 }
6353 }
6454
65- // Check if current has a 'type' field (it's a leaf with type definition)
66- // but we're trying to go deeper - this means the path doesn't exist
6755 if ( 'type' in current && typeof current . type === 'string' ) {
68- // It's a typed field, can't go deeper unless it has properties
6956 if ( ! current . properties && ! current . items ) {
7057 return false
7158 }
7259 }
7360
74- // Path part not found in schema
7561 return false
7662 }
7763
7864 return true
7965}
8066
81- /**
82- * Get available top-level field names from an output schema for error messages.
83- */
8467function getSchemaFieldNames ( outputs : Record < string , any > | undefined ) : string [ ] {
8568 if ( ! outputs ) return [ ]
8669 return Object . keys ( outputs )
@@ -185,9 +168,6 @@ export class BlockResolver implements Resolver {
185168 }
186169 }
187170
188- // Path not found in data - check if it exists in the schema
189- // If path is NOT in schema, it's likely a typo - throw an error
190- // If path IS in schema but data is missing, it's an optional field - return undefined
191171 const schemaFields = getSchemaFieldNames ( block ?. outputs )
192172 if ( schemaFields . length > 0 && ! isPathInOutputSchema ( block ?. outputs , pathParts ) ) {
193173 throw new Error (
@@ -196,7 +176,6 @@ export class BlockResolver implements Resolver {
196176 )
197177 }
198178
199- // Path exists in schema but data is missing - return undefined (optional field)
200179 return undefined
201180 }
202181
0 commit comments