From cc339e5246eda00fbf24ea7f38251dd3117f6774 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Wed, 21 Oct 2026 10:05:55 +0000 Subject: [PATCH] test(cli): treat omitted exactOptional inputs as optional The advertised-schema check parsed undefined on each field. exactOptional rejects that value and still accepts a missing key, so inspect-wasm-artifact looked required for commandTimeoutMs. Judge omission with an object parse that leaves the key out. The advertised required list already matched that parse for every other primary command. Co-authored-by: morluto --- tests/boundary/cli/cliInputSchemaRequired.test.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tests/boundary/cli/cliInputSchemaRequired.test.ts b/tests/boundary/cli/cliInputSchemaRequired.test.ts index 1bf778b7a76..29d29fe620f 100644 --- a/tests/boundary/cli/cliInputSchemaRequired.test.ts +++ b/tests/boundary/cli/cliInputSchemaRequired.test.ts @@ -61,12 +61,19 @@ const parserSchema = ( return schema instanceof z.ZodObject ? schema : undefined; }; +/** + * Reject a key only when an object parse that omits it fails. + * `exactOptional()` rejects explicit `undefined` and still accepts omission. + */ const omissionRejected = (schema: z.ZodObject | undefined): string[] => Object.entries(schema?.shape ?? {}) - .filter(([, field]) => !field.safeParse(undefined).success) + .filter(([key, field]) => !acceptsOmittedKey(key, field)) .map(([key]) => key) .sort(); +const acceptsOmittedKey = (key: string, field: z.ZodType): boolean => + z.object({ [key]: field }).safeParse({}).success; + describe("CLI advertised input schemas", () => { it("require exactly the inputs whose omission the parser rejects", async () => { const cli = createCli({});