chore(provider): format zod errors compactly for run.errors#86
Open
coletebou wants to merge 1 commit into
Open
chore(provider): format zod errors compactly for run.errors#86coletebou wants to merge 1 commit into
coletebou wants to merge 1 commit into
Conversation
Replace raw ZodError JSON blobs in run.errors[].message with one-line path=value (code, expected ...) summaries. Adds formatZodIssue / formatZodError helpers and a parseOrThrow wrapper. Replaces the 16 schema.parse(output) call sites across codex, opencode, acpx, and grok providers (map / review / fix / revalidate). Behavior is unchanged: still throws ClawpatchError with code 'malformed-output' and exit code 8 — only the message text is compact. Bad values for enum mismatches are looked up from the original input via the issue path (zod 4 omits 'received' for invalid_value).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When
reviewOutputSchema.parse()(or any of the 16 provider-output parses) throws on bad model output, the error embeds the entire ~1.5KB zod issue blob inrun.errors[].message. Operators tailing a log can't easily see what went wrong.This PR wraps every provider-output parse with a small
parseOrThrowhelper that emits one-line summaries:Three issues max, then
(+N more). Values truncated to 80 chars.Files
src/provider.ts— new helpers (formatZodPath,previewZodValue,lookupAtPath,formatZodIssue,formatZodError,parseOrThrow); 16.parse(output)call sites swapped toparseOrThrow(...)with descriptive labels (codex map,codex review, …,pi revalidate)src/provider.test.ts— 6 new cases (4 formatter, 2 wrapper)The Pi provider added in #50 had four un-wrapped
.parse(output)calls; this PR wraps those too, sogit grep ".parse(output)" src/returns empty after merge.Why
Run
20260517T190759-3c9e9ehad 26 zod-throw errors. Each one's message inrun.errors[].messagewas 1.5KB of nested JSON. After this PR the operator-relevant info (path+ sample bad value) is on a single line.Validation
pnpm format:check— cleanpnpm typecheck— cleanpnpm lint— cleanpnpm build— cleanpnpm test— 547 passed, 1 skipped (+6 new)Coordination
Layered cleanly on the safeparse-partition PR — if that one lands first, this PR's
formatZodErrorbecomes the drop-reason rendering. They merge in either order.