Repository navigation
refactor(server, contract): share toPublicSchemaIssue - #2569
Conversation
Move the issue mapping from #2568 into `toPublicSchemaIssue` in `@orpc/contract`, used by the server and `RequestValidationLinkPlugin`, and drop the migration-guide note since v1 gets the same change.
More templates
@orpc/ai-sdk
@orpc/arktype
@orpc/bun
@orpc/client
@orpc/cloudflare
@orpc/contract
@orpc/effect
@orpc/evlog
@orpc/hibernation
@orpc/json-schema
@orpc/experimental-lock
@orpc/mcp
@orpc/msw
@orpc/nest
@orpc/next
@orpc/node
@orpc/openapi
@orpc/experimental-openapi-inference
@orpc/opentelemetry
@orpc/pinia-colada
@orpc/pino
@orpc/publisher
@orpc/ratelimit
@orpc/server
@orpc/shared
@orpc/swr
@orpc/tanstack-query
@orpc/trpc
@orpc/valibot
@orpc/zod
commit: |
|
No actionable comments were generated in the recent review. Summary
Merge Risk:
|
There was a problem hiding this comment.
ℹ️ Minor suggestion inline.
Approach: sound — the projection now lives in @orpc/contract, so the server and the client-side plugin cannot drift apart on the wire shape.
Reviewed changes
- Shared projection:
toPublicSchemaIssueadded toschema-utils.tsand adopted byvalidateInputandRequestValidationLinkPlugin, replacing the two duplicated inline maps. - Tests: the server's two issue-shape tests collapse into one that also asserts the raw issues stay on
error.cause; a focused unit test covers{ key }path segments and an issue withoutpath. - Docs: the
from-v1migration note added by #2568 is removed, since #2567 shipped the same projection on1.x.
deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏
| typeof segment === 'object' ? { key: segment.key } : segment, | ||
| ), | ||
| })), | ||
| issues: result.issues.map(toPublicSchemaIssue), |
There was a problem hiding this comment.
Unlike the v1 fix (#2567), this maps in place, so data.issues keeps the array type the schema vendor returned. A vendor whose issues array is an Array subclass that does not override Symbol.species (the motivating ArkType ArkErrors case, whose toJSON assumes its elements are ArkErrors) then puts that subclass on the wire, where toJSON sees plain { message, path } objects. Array.from keeps data.issues a plain array, as v1 does and tests; apply the same at packages/contract/src/plugins/request-validation.ts:64.
| issues: result.issues.map(toPublicSchemaIssue), | |
| issues: Array.from(result.issues, toPublicSchemaIssue), |
There was a problem hiding this comment.
Checked with the installed ArkType: result.issues is an ArkErrors, but .map already returns a plain Array, and a request through RPCHandler gets a normal 400 with plain { message, path } issues. So I kept .map, since it's the simpler form here.
🤖 Addressed by Claude Code
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Merging this PR will not alter performance1 warning
Comparing Footnotes
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
orpc | 62adc5a | Commit Preview URL Branch Preview URL |
Nov 30 2026, 12:56 AM |

Follow-up to #2568.
toPublicSchemaIssuein@orpc/contract, used byvalidateInputin the server and byRequestValidationLinkPlugin.