3232 * register it too. Either way the finding says the flow could not be judged
3333 * and carries the schema's issues.
3434 *
35+ * An entry that is not a record at all (an empty YAML list item, a string) is
36+ * skipped, as every registry reader skips it (`non-record-object-entry.test.ts`):
37+ * no author wrote a flow there, and `os validate` refuses the collection with
38+ * the stack schema's own sentence. Its index is kept, so the paths of the
39+ * flows around it stay the author's.
40+ *
3541 * ## Not judged here
3642 *
3743 * A cycle in the flow's TOP-LEVEL graph. The engine refuses it with
@@ -43,6 +49,8 @@ import { FlowSchema, validateControlFlow } from '@objectstack/spec/automation';
4349
4450type AnyRec = Record < string , unknown > ;
4551
52+ const isRec = ( v : unknown ) : v is AnyRec => ! ! v && typeof v === 'object' && ! Array . isArray ( v ) ;
53+
4654/** The rule id every finding of this rule carries. */
4755export const FLOW_REGION_SHAPE_INVALID = 'flow-region-shape-invalid' ;
4856
@@ -77,10 +85,11 @@ export function validateFlowRegionShape(stack: AnyRec): FlowRegionShapeFinding[]
7785 if ( ! Array . isArray ( flows ) ) return [ ] ;
7886 const findings : FlowRegionShapeFinding [ ] = [ ] ;
7987 flows . forEach ( ( raw , i ) => {
88+ if ( ! isRec ( raw ) ) return ;
8089 const path = `flows[${ i } ]` ;
8190 const result = FlowSchema . safeParse ( raw ) ;
8291 if ( ! result . success ) {
83- const declared = ( raw as { name ?: unknown } | null ) ? .name ;
92+ const declared = raw . name ;
8493 const name = typeof declared === 'string' && declared !== '' ? declared : path ;
8594 const issues = result . error . issues
8695 . map ( ( issue ) => `${ issue . path . length > 0 ? issue . path . join ( '.' ) : '(root)' } : ${ issue . message } ` )
0 commit comments