Skip to content

Commit ce893bb

Browse files
committed
refactor(spec): route the strict:false objects refusal through describeNonArrayCollection
Claude-Session: https://claude.ai/code/session_01VWsFyWDp8Rjb2Ma6a3Cyo8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3653b81 commit ce893bb

1 file changed

Lines changed: 2 additions & 11 deletions

File tree

‎packages/spec/src/stack.zod.ts‎

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2960,22 +2960,13 @@ function mergeActionsIntoObjects(config: ObjectStackDefinition): ObjectStackDefi
29602960
// `mergeObjects` draws for the same key.
29612961
const declaredObjects: unknown = (config as { objects?: unknown }).objects;
29622962
if (declaredObjects !== undefined && !Array.isArray(declaredObjects)) {
2963-
const parsed = z.array(z.unknown()).safeParse(declaredObjects);
2964-
const issues = parsed.success
2965-
? []
2966-
: parsed.error.issues.map((issue) => ({ ...issue, path: ['objects', ...issue.path] }));
2967-
const kind =
2968-
declaredObjects === null
2969-
? 'null'
2970-
: typeof declaredObjects !== 'object'
2971-
? `a ${typeof declaredObjects}`
2972-
: `a ${(declaredObjects as object).constructor?.name ?? 'non-plain'} object`;
2963+
const { kind, issues } = describeNonArrayCollection('objects', declaredObjects);
29732964
throw new StackSchemaInvalidError(
29742965
`defineStack validation failed: 'objects' is ${kind}, not an array. Bound actions cannot be ` +
29752966
`merged into it, and \`strict: false\` skips validation, not this shape — \`composeStacks\` ` +
29762967
`refuses the same stack with the same code. Author 'objects' as an array or in the map form ` +
29772968
`(\`{ name: { … } }\`), or drop \`strict: false\` to have every schema check run.`,
2978-
issues as z.core.$ZodIssue[],
2969+
issues,
29792970
);
29802971
}
29812972

0 commit comments

Comments
 (0)