STET

agent_patch

runs/2026-02-27__21-30-28__gpt-5-1-codex-mini/flux-pr-4672/flux-pr-4672.1-of-1.2026-02-27__21-30-28__gpt-5-1-codex-mini/agent-logs/agent.patch

7836 bytes

Back to adjudication
diff --git a/tmp/agent-patch-flux-pr-4672.1-of-1.2026-02-27__21-30-28__gpt-5-1-codex-mini/app/packages/zod/src/v4/classic/parse.ts b/app/packages/zod/src/v4/classic/parse.ts
index 8304dd9..61bc4c8 100644
--- a/tmp/agent-patch-flux-pr-4672.1-of-1.2026-02-27__21-30-28__gpt-5-1-codex-mini/app/packages/zod/src/v4/classic/parse.ts
+++ b/app/packages/zod/src/v4/classic/parse.ts
@@ -10,24 +10,24 @@ export const parse: <T extends core.$ZodType>(
   value: unknown,
   _ctx?: core.ParseContext<core.$ZodIssue>,
   _params?: { callee?: core.util.AnyFunc; Err?: core.$ZodErrorClass }
-) => core.output<T> = /* @__PURE__ */ core._parse(ZodRealError) as any;
+) => core.output<T> = /* @__PURE__ */ core._parse(ZodRealError);
 
 export const parseAsync: <T extends core.$ZodType>(
   schema: T,
   value: unknown,
   _ctx?: core.ParseContext<core.$ZodIssue>,
   _params?: { callee?: core.util.AnyFunc; Err?: core.$ZodErrorClass }
-) => Promise<core.output<T>> = /* @__PURE__ */ core._parseAsync(ZodRealError) as any;
+) => Promise<core.output<T>> = /* @__PURE__ */ core._parseAsync(ZodRealError);
 
 export const safeParse: <T extends core.$ZodType>(
   schema: T,
   value: unknown,
   _ctx?: core.ParseContext<core.$ZodIssue>
   // _params?: { callee?: core.util.AnyFunc; Err?: core.$ZodErrorClass }
-) => ZodSafeParseResult<core.output<T>> = /* @__PURE__ */ core._safeParse(ZodRealError) as any;
+) => ZodSafeParseResult<core.output<T>> = /* @__PURE__ */ core._safeParse(ZodRealError);
 
 export const safeParseAsync: <T extends core.$ZodType>(
   schema: T,
   value: unknown,
   _ctx?: core.ParseContext<core.$ZodIssue>
-) => Promise<ZodSafeParseResult<core.output<T>>> = /* @__PURE__ */ core._safeParseAsync(ZodRealError) as any;
+) => Promise<ZodSafeParseResult<core.output<T>>> = /* @__PURE__ */ core._safeParseAsync(ZodRealError);
diff --git a/tmp/agent-patch-flux-pr-4672.1-of-1.2026-02-27__21-30-28__gpt-5-1-codex-mini/app/packages/zod/src/v4/core/errors.ts b/app/packages/zod/src/v4/core/errors.ts
index fb4757b..85a357b 100644
--- a/tmp/agent-patch-flux-pr-4672.1-of-1.2026-02-27__21-30-28__gpt-5-1-codex-mini/app/packages/zod/src/v4/core/errors.ts
+++ b/app/packages/zod/src/v4/core/errors.ts
@@ -244,15 +244,17 @@ export type $ZodFormattedError<T, U = string> = {
   _errors: U[];
 } & util.Flatten<_ZodFormattedError<T, U>>;
 
+type FormatValue<U> = U extends undefined ? string : U;
+
+type FormattedErrorNode<U> = {
+  _errors: U[];
+} & Record<PropertyKey, FormattedErrorNode<U> | undefined>;
+
 export function formatError<T>(error: $ZodError<T>): $ZodFormattedError<T>;
-export function formatError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;
-export function formatError<T>(error: $ZodError, _mapper?: any) {
-  const mapper: (issue: $ZodIssue) => any =
-    _mapper ||
-    function (issue: $ZodIssue) {
-      return issue.message;
-    };
-  const fieldErrors: $ZodFormattedError<T> = { _errors: [] } as any;
+export function formatError<T, U>(error: $ZodError<T>, mapper: (issue: $ZodIssue) => U): $ZodFormattedError<T, U>;
+export function formatError<T, U>(error: $ZodError, mapper?: (issue: $ZodIssue) => U): $ZodFormattedError<T, FormatValue<U>> {
+  const resolve = (issue: $ZodIssue) => (mapper ? mapper(issue) : issue.message) as FormatValue<U>;
+  const fieldErrors: FormattedErrorNode<FormatValue<U>> = { _errors: [] };
   const processError = (error: { issues: $ZodIssue[] }) => {
     for (const issue of error.issues) {
       if (issue.code === "invalid_union" && issue.errors.length) {
@@ -262,29 +264,26 @@ export function formatError<T>(error: $ZodError, _mapper?: any) {
       } else if (issue.code === "invalid_element") {
         processError({ issues: issue.issues });
       } else if (issue.path.length === 0) {
-        (fieldErrors as any)._errors.push(mapper(issue));
+        fieldErrors._errors.push(resolve(issue));
       } else {
-        let curr: any = fieldErrors;
+        let curr: FormattedErrorNode<FormatValue<U>> = fieldErrors;
         let i = 0;
         while (i < issue.path.length) {
           const el = issue.path[i];
           const terminal = i === issue.path.length - 1;
-
-          if (!terminal) {
-            curr[el] = curr[el] || { _errors: [] };
-          } else {
-            curr[el] = curr[el] || { _errors: [] };
-            curr[el]._errors.push(mapper(issue));
-          }
-
-          curr = curr[el];
+        const next = curr[el] ?? (curr[el] = { _errors: [] });
+        if (terminal) {
+          next._errors.push(resolve(issue));
+        } else {
+          curr = next;
+        }
           i++;
         }
       }
     }
   };
   processError(error);
-  return fieldErrors;
+  return fieldErrors as $ZodFormattedError<T, FormatValue<U>>;
 }
 
 export type $ZodErrorTree<T, U = string> = T extends [any, ...any[]]
@@ -295,15 +294,19 @@ export type $ZodErrorTree<T, U = string> = T extends [any, ...any[]]
       ? { errors: U[]; properties?: { [K in keyof T]?: $ZodErrorTree<T[K], U> } }
       : { errors: U[] };
 
+type TreeValue<U> = U extends undefined ? string : U;
+
+type TreeNode<U> = {
+  errors: U[];
+  properties?: Record<string, TreeNode<U>>;
+  items?: TreeNode<U>[];
+};
+
 export function treeifyError<T>(error: $ZodError<T>): $ZodErrorTree<T>;
-export function treeifyError<T, U>(error: $ZodError<T>, mapper?: (issue: $ZodIssue) => U): $ZodErrorTree<T, U>;
-export function treeifyError<T>(error: $ZodError, _mapper?: any) {
-  const mapper: (issue: $ZodIssue) => any =
-    _mapper ||
-    function (issue: $ZodIssue) {
-      return issue.message;
-    };
-  const result: $ZodErrorTree<T> = { errors: [] } as any;
+export function treeifyError<T, U>(error: $ZodError<T>, mapper: (issue: $ZodIssue) => U): $ZodErrorTree<T, U>;
+export function treeifyError<T, U>(error: $ZodError, mapper?: (issue: $ZodIssue) => U): $ZodErrorTree<T, TreeValue<U>> {
+  const resolve = (issue: $ZodIssue) => (mapper ? mapper(issue) : issue.message) as TreeValue<U>;
+  const result: TreeNode<TreeValue<U>> = { errors: [] };
   const processError = (error: { issues: $ZodIssue[] }, path: PropertyKey[] = []) => {
     for (const issue of error.issues) {
       if (issue.code === "invalid_union" && issue.errors.length) {
@@ -316,28 +319,28 @@ export function treeifyError<T>(error: $ZodError, _mapper?: any) {
       } else {
         const fullpath = [...path, ...issue.path];
         if (fullpath.length === 0) {
-          result.errors.push(mapper(issue));
+          result.errors.push(resolve(issue));
           continue;
         }
 
-        let curr: any = result;
+        let curr: TreeNode<TreeValue<U>> = result;
         let i = 0;
         while (i < fullpath.length) {
           const el = fullpath[i];
-
           const terminal = i === fullpath.length - 1;
           if (typeof el === "string") {
             curr.properties ??= {};
-            curr.properties[el] ??= { errors: [] };
-            curr = curr.properties[el];
+            const next = curr.properties[el] ?? (curr.properties[el] = { errors: [] });
+            curr = next;
           } else {
             curr.items ??= [];
-            curr.items[el] ??= { errors: [] };
-            curr = curr.items[el];
+            const index = el as number;
+            const next = curr.items[index] ?? (curr.items[index] = { errors: [] });
+            curr = next;
           }
 
           if (terminal) {
-            curr.errors.push(mapper(issue));
+            curr.errors.push(resolve(issue));
           }
 
           i++;
@@ -346,7 +349,7 @@ export function treeifyError<T>(error: $ZodError, _mapper?: any) {
     }
   };
   processError(error);
-  return result;
+  return result as $ZodErrorTree<T, TreeValue<U>>;
 }
 
 /** Format a ZodError as a human-readable string in the following form.