Skip to content

refactor(server, contract): share toPublicSchemaIssue - #2569

Merged
dinwwwh merged 1 commit into
mainfrom
claude/share-public-schema-issue
Nov 30, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/share-public-schema-issue

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 30, 2026

Copy link
Copy Markdown
Member

Follow-up to #2568.

  • Move the validation issue mapping into toPublicSchemaIssue in @orpc/contract, used by validateInput in the server and by RequestValidationLinkPlugin.
  • Remove the migration-guide note, since v1 ships the same change.

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.
@pkg-pr-new

pkg-pr-new Bot commented Nov 30, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

npm i https://pkg.pr.new/@orpc/ai-sdk@2569

@orpc/arktype

npm i https://pkg.pr.new/@orpc/arktype@2569

@orpc/bun

npm i https://pkg.pr.new/@orpc/bun@2569

@orpc/client

npm i https://pkg.pr.new/@orpc/client@2569

@orpc/cloudflare

npm i https://pkg.pr.new/@orpc/cloudflare@2569

@orpc/contract

npm i https://pkg.pr.new/@orpc/contract@2569

@orpc/effect

npm i https://pkg.pr.new/@orpc/effect@2569

@orpc/evlog

npm i https://pkg.pr.new/@orpc/evlog@2569

@orpc/hibernation

npm i https://pkg.pr.new/@orpc/hibernation@2569

@orpc/json-schema

npm i https://pkg.pr.new/@orpc/json-schema@2569

@orpc/experimental-lock

npm i https://pkg.pr.new/@orpc/experimental-lock@2569

@orpc/mcp

npm i https://pkg.pr.new/@orpc/mcp@2569

@orpc/msw

npm i https://pkg.pr.new/@orpc/msw@2569

@orpc/nest

npm i https://pkg.pr.new/@orpc/nest@2569

@orpc/next

npm i https://pkg.pr.new/@orpc/next@2569

@orpc/node

npm i https://pkg.pr.new/@orpc/node@2569

@orpc/openapi

npm i https://pkg.pr.new/@orpc/openapi@2569

@orpc/experimental-openapi-inference

npm i https://pkg.pr.new/@orpc/experimental-openapi-inference@2569

@orpc/opentelemetry

npm i https://pkg.pr.new/@orpc/opentelemetry@2569

@orpc/pinia-colada

npm i https://pkg.pr.new/@orpc/pinia-colada@2569

@orpc/pino

npm i https://pkg.pr.new/@orpc/pino@2569

@orpc/publisher

npm i https://pkg.pr.new/@orpc/publisher@2569

@orpc/ratelimit

npm i https://pkg.pr.new/@orpc/ratelimit@2569

@orpc/server

npm i https://pkg.pr.new/@orpc/server@2569

@orpc/shared

npm i https://pkg.pr.new/@orpc/shared@2569

@orpc/swr

npm i https://pkg.pr.new/@orpc/swr@2569

@orpc/tanstack-query

npm i https://pkg.pr.new/@orpc/tanstack-query@2569

@orpc/trpc

npm i https://pkg.pr.new/@orpc/trpc@2569

@orpc/valibot

npm i https://pkg.pr.new/@orpc/valibot@2569

@orpc/zod

npm i https://pkg.pr.new/@orpc/zod@2569

commit: 62adc5a

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Validation errors now expose only public issue details, retaining messages and paths while excluding private input data. Original issues remain available in the underlying error.
  • Documentation
    • The migration guide no longer lists which validation-issue fields appear in error data or where complete issues are available.

Validation issue conversion now uses a shared function in contract validation and server error data. Public issues retain messages and paths, with object path segments reduced to keys. Server errors retain the original issues in error.cause.issues.

Changes: Validation issue sanitization

Layer / File(s) Summary
Define and use public issue conversion
packages/contract/src/schema-utils.ts, packages/contract/src/plugins/request-validation.ts, packages/contract/src/schema-utils.test.ts, apps/content/docs/migrations/from-v1.mdx
The new toPublicSchemaIssue function copies the message and path, reduces object path segments to { key }, and retains other segments. Request validation uses the function. Tests cover paths with and without segments. The migration guide subsection about retained issue fields is removed.
Apply conversion to server error data
packages/server/src/procedure-client.ts, packages/server/src/procedure-client.test.ts
BAD_REQUEST error data uses toPublicSchemaIssue. The test checks sanitized public issues and verifies that error.cause.issues retains the original issue array.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: Minimal · up to 62adc

This change centralizes how validation issues are exposed publicly. It keeps only the message and path, and reduces object path segments to their keys. Tests cover the conversion and the retained original issues, and no merge-blocking risk is evident.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: a refactor that moves the public schema issue mapping into a shared toPublicSchemaIssue helper used by the server and contract packages. It follows the conventional-…
Description check Passed The description states the change. It says the validation issue mapping moved into toPublicSchemaIssue in @orpc/contract, used by validateInput on the server and by RequestValidationLinkPlugin…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: a refactor that moves the public schema issue mapping into a shared toPublicSchemaIssue helper used by the server and contract packages. It follows the conventional-commit style and is specific enough for a reader scanning history.

Full details: Description check

Explanation

The description states the change. It says the validation issue mapping moved into toPublicSchemaIssue in @orpc/contract, used by validateInput on the server and by RequestValidationLinkPlugin. It also says the migration-guide note was removed, which matches the raw summary's changes to apps/content/docs/migrations/from-v1.mdx.

  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fca9cb55-22a6-4b3b-b6ae-7e38b488e5de
Commits

Reviewing files that changed from the base of the PR and between 2ffa735 and 62adc5a.

Files selected for processing: 6

  • apps/content/docs/migrations/from-v1.mdx
  • packages/contract/src/plugins/request-validation.ts
  • packages/contract/src/schema-utils.test.ts
  • packages/contract/src/schema-utils.ts
  • packages/server/src/procedure-client.test.ts
  • packages/server/src/procedure-client.ts
Files with no reviewable changes: 1

  • apps/content/docs/migrations/from-v1.mdx

Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ 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: toPublicSchemaIssue added to schema-utils.ts and adopted by validateInput and RequestValidationLinkPlugin, 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 without path.
  • Docs: the from-v1 migration note added by #2568 is removed, since #2567 shipped the same projection on 1.x.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using deepseek-v4.1-flash-1017 (free via Pullfrog for OSS) | 𝕏

typeof segment === 'object' ? { key: segment.key } : segment,
),
})),
issues: result.issues.map(toPublicSchemaIssue),

@pullfrog pullfrog Bot Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
issues: result.issues.map(toPublicSchemaIssue),
issues: Array.from(result.issues, toPublicSchemaIssue),

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

codecov Bot commented Nov 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@codspeed

codspeed Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ 5 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

✅ 40 untouched benchmarks
⏩ 2 skipped benchmarks1


Comparing claude/share-public-schema-issue (62adc5a) with main (2ffa735)

Open in CodSpeed

Footnotes

  1. 2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

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

@dinwwwh
dinwwwh merged commit 34e1142 into main Nov 30, 2026
13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant