QVAC-20529 fix[api]: friendly, field-level validation errors for user input#2618
Merged
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
Tier-based Approval Status |
simon-iribarren
approved these changes
Jun 16, 2026
e22d429 to
fb930b7
Compare
Contributor
QVAC E2E —
|
Contributor
Contributor
QVAC E2E —
|
Contributor
QVAC E2E —
|
Contributor
opaninakuffo
approved these changes
Jun 16, 2026
Signed-off-by: Arun Mani J <j.arunmani@proton.me>
Signed-off-by: Arun Mani J <j.arunmani@proton.me>
4239018 to
61c6d20
Compare
Contributor
Author
|
review |
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.
🎯 What problem does this PR solve?
modelConfigkey madeloadModelreject with a multi-KB rawZodErrorJSON blob that leaked into the renderer UI — a wall of JSON instead of areadable message.
ZodErrors (whose.messageis serializedJSON), and the
modelType/config schemas arez.unions, so even when caught Zodreported a generic "Invalid input" across every branch instead of the actual field.
📝 How does it solve it?
formatZodError(wraps Zod v4's built-inz.prettifyError) is the single errorformatter; replaces the duplicated
error.issues.map(...)blocks.parseClientInput) and throws a typedRequestValidationFailedError(code 50010) with a prettified, non-JSON message;createErrorResponseprettifies anyZodErroron the wire. The UI never receivesraw serialized ZodError JSON.
modelType-keyed load-model unions and thettsEngine-keyed tts/translateconfig unions became
z.discriminatedUnions, andparseRequestre-validates afailed request against the member owning its
type— so errors name the offendingfield instead of collapsing to "Invalid input".
responses (SDK bugs, dev-facing) intentionally stay raw.
🧪 How was it tested?
test/unit/zod-error-formatting.test.ts(14 tests): no-JSON guarantees,loadModel/tts field-level errors, per-op
typedispatch (embed/transcribe/translate)through the real
send()path.bun run test:unitpasses;bun run lintclean.examples/quickstart.ts+bun examples/quickstart.ts:modelConfg: {...}ZodError: [ { "code": "invalid_union", "errors": [[ … ]] } ](multi-KB blob)Invalid request:✖ Unrecognized key: "modelConfg"modelConfig: { dtx_size: 4096 }Invalid request:✖ Unrecognized key: "dtx_size"→ at modelConfig🔌 API Changes
New exported error class
RequestValidationFailedError(code 50010) for catchinginvalid-input rejections: