agent_patch
runs/2026-02-27__21-30-28__gpt-5-4/flux-pr-4861/flux-pr-4861.1-of-1.2026-02-27__21-30-28__gpt-5-4/agent-logs/agent.patch
3909 bytes
diff --git a/tmp/agent-patch-flux-pr-4861.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/packages/zod/src/v4/classic/tests/discriminated-unions.test.ts b/app/packages/zod/src/v4/classic/tests/discriminated-unions.test.ts
index 9aba3df..0e00e4e 100644
--- a/tmp/agent-patch-flux-pr-4861.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/packages/zod/src/v4/classic/tests/discriminated-unions.test.ts
+++ b/app/packages/zod/src/v4/classic/tests/discriminated-unions.test.ts
@@ -60,6 +60,55 @@ test("valid - optional discriminator (object)", () => {
expect(schema.parse({ a: "abc" })).toEqual({ a: "abc" });
});
+test("valid - object option wrapped in pipe", () => {
+ const schema = z.discriminatedUnion("type", [
+ z.object({ type: z.literal("a"), a: z.string() }).transform((value) => ({
+ ...value,
+ a: value.a.toUpperCase(),
+ })),
+ z.object({ type: z.literal("b"), b: z.string() }),
+ ]);
+
+ expect(schema.parse({ type: "a", a: "abc" })).toEqual({ type: "a", a: "ABC" });
+});
+
+test("valid - preprocess wrapped option", () => {
+ const schema = z.discriminatedUnion("type", [
+ z.object({ type: z.literal("a"), a: z.string() }),
+ z.preprocess(
+ (value) => {
+ if (!value || typeof value !== "object") return value;
+ return {
+ ...value,
+ b: String((value as { b?: unknown }).b),
+ };
+ },
+ z.object({ type: z.literal("b"), b: z.string().min(2) })
+ ),
+ ]);
+
+ expect(schema.parse({ type: "b", b: 12 })).toEqual({ type: "b", b: "12" });
+
+ const result = schema.safeParse({ type: "b", b: 1 });
+ expect(result).toMatchInlineSnapshot(`
+ {
+ "error": [ZodError: [
+ {
+ "origin": "string",
+ "code": "too_small",
+ "minimum": 2,
+ "inclusive": true,
+ "path": [
+ "b"
+ ],
+ "message": "Too small: expected string to have >=2 characters"
+ }
+ ]],
+ "success": false,
+ }
+ `);
+});
+
test("valid - discriminator value of various primitive types", () => {
const schema = z.discriminatedUnion("type", [
z.object({ type: z.literal("1"), val: z.string() }),
diff --git a/tmp/agent-patch-flux-pr-4861.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/packages/zod/src/v4/core/schemas.ts b/app/packages/zod/src/v4/core/schemas.ts
index 85f4e23..23052e5 100644
--- a/tmp/agent-patch-flux-pr-4861.1-of-1.2026-02-27__21-30-28__gpt-5-4/app/packages/zod/src/v4/core/schemas.ts
+++ b/app/packages/zod/src/v4/core/schemas.ts
@@ -3426,6 +3426,7 @@ export interface $ZodPipeInternals<A extends SomeType = $ZodType, B extends Some
extends $ZodTypeInternals<core.output<B>, core.input<A>> {
def: $ZodPipeDef<A, B>;
isst: never;
+ propValues: util.PropValues | undefined;
values: A["_zod"]["values"];
optin: A["_zod"]["optin"];
optout: B["_zod"]["optout"];
@@ -3437,6 +3438,23 @@ export interface $ZodPipe<A extends SomeType = $ZodType, B extends SomeType = $Z
export const $ZodPipe: core.$constructor<$ZodPipe> = /*@__PURE__*/ core.$constructor("$ZodPipe", (inst, def) => {
$ZodType.init(inst, def);
+ util.defineLazy(inst._zod, "propValues", () => {
+ const inputPropValues = def.in._zod.propValues;
+ const outputPropValues = def.out._zod.propValues;
+
+ if (!inputPropValues) return outputPropValues;
+ if (!outputPropValues) return inputPropValues;
+
+ const propValues: util.PropValues = {};
+ for (const [key, values] of Object.entries(inputPropValues)) {
+ propValues[key] = new Set(values);
+ }
+ for (const [key, values] of Object.entries(outputPropValues)) {
+ if (propValues[key]) continue;
+ propValues[key] = new Set(values);
+ }
+ return propValues;
+ });
util.defineLazy(inst._zod, "values", () => def.in._zod.values);
util.defineLazy(inst._zod, "optin", () => def.in._zod.optin);
util.defineLazy(inst._zod, "optout", () => def.out._zod.optout);