Skip to content

armgit / rea

Public Imported from GitHub
0

Reverse engineer anything with agents, from app behavior down to native binaries.

test(cli): treat omitted exactOptional inputs as optional

Cursor Agent5eebe2fdf879
diff --git a/tests/boundary/cli/cliInputSchemaRequired.test.ts b/tests/boundary/cli/cliInputSchemaRequired.test.ts
index 29a5c7f76..3fae2290d 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(([key, field]) => !z.object({ [key]: field }).safeParse({}).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({});