Skip to content

fix(trpc): carry every chained tRPC input schema into the oRPC procedure - #2542

Merged
dinwwwh merged 1 commit into
mainfrom
claude/trpc-all-inputs-f4acdc
Nov 23, 2026
Merged

dinwwwh merged 1 commit into
mainfrom
claude/trpc-all-inputs-f4acdc

Conversation

@dinwwwh

@dinwwwh dinwwwh commented Nov 23, 2026

Copy link
Copy Markdown
Member

What

toORPCRouter built the oRPC procedure's input schema from the last entry of tRPC's _def.inputs only. A procedure with chained inputs, t.procedure.input(z.object({ x })).input(z.object({ y })), produced a contract and OpenAPI request body containing only y, while tRPC still validated both at runtime, so a request built from the generated spec failed on x.

Every entry of _def.inputs that is a Standard Schema is now passed as inputSchemas, which the OpenAPI generator combines with allOf.

Notes for review

  • oRPC's own input validation stays disabled for converted procedures (disableInputValidation: true), so tRPC remains the only validator and nothing is validated twice.
  • Non-standard function parsers are skipped, as before.
  • Outputs are unaffected: tRPC keeps a single _def.output, replaced on each .output() call.
  • Not breaking. Generated specs for chained-input procedures gain the fields that were missing.

Tests

Two and three chained inputs: the resulting contract, the generated OpenAPI request body, and real calls (success and BAD_REQUEST on a missing field), plus skipping a non-standard parser.

@pkg-pr-new

pkg-pr-new Bot commented Nov 23, 2026

Copy link
Copy Markdown
More templates

@orpc/ai-sdk

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

@orpc/arktype

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

@orpc/bun

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

@orpc/client

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

@orpc/cloudflare

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

@orpc/contract

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

@orpc/effect

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

@orpc/evlog

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

@orpc/hibernation

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

@orpc/json-schema

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

@orpc/experimental-lock

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

@orpc/mcp

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

@orpc/msw

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

@orpc/nest

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

@orpc/next

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

@orpc/node

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

@orpc/openapi

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

@orpc/experimental-openapi-inference

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

@orpc/opentelemetry

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

@orpc/pinia-colada

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

@orpc/pino

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

@orpc/publisher

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

@orpc/ratelimit

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

@orpc/server

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

@orpc/shared

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

@orpc/swr

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

@orpc/tanstack-query

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

@orpc/trpc

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

@orpc/valibot

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

@orpc/zod

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

commit: d41493d

@coderabbitai

coderabbitai Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Explain Change →

No actionable comments were generated in the recent review.

Summary

Summary by CodeRabbit

  • Bug Fixes
    • Router conversion now retains all supported input schemas in chained tRPC procedures, so generated request bodies include fields from each schema and required fields are validated.
  • Documentation
    • Clarified that converted schemas are carried over while input validation continues to run in tRPC.

The tRPC router conversion now collects standard schemas from all chained input parsers, skips parsers without a standard schema, and passes the remaining schemas to the oRPC procedure. Tests cover OpenAPI request bodies and input validation. The documentation describes schema conversion and tRPC validation.

Changes: tRPC Input Conversion

Layer / File(s) Summary
Collect and validate chained input schemas
packages/trpc/src/to-orpc-router.ts, packages/trpc/src/to-orpc-router.test.ts, apps/content/docs/integrations/trpc.mdx
The conversion collects standard schemas from all input parsers in order and passes them to the procedure when any remain. Tests cover combined OpenAPI request bodies, valid inputs, and missing required fields. The documentation describes chained input schemas and states that validation runs inside tRPC.

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

Change: Bug fix

Merge Risk: Minimal · up to d4149

Converted tRPC procedures with chained inputs now expose every input schema in the oRPC contract and OpenAPI request body. Validation is still performed by tRPC. No merge-blocking risk was identified.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: the tRPC-to-oRPC conversion now carries every chained input schema, not only the last one. The title matches the raw summary, the description, and the PR objectives. I…
Description check Passed The description explains the bug: only the last entry of tRPC's inputs was used, so chained inputs were missing from the contract and OpenAPI request body. It describes the fix (passing every Standard…
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: the tRPC-to-oRPC conversion now carries every chained input schema, not only the last one. The title matches the raw summary, the description, and the PR objectives. It is a short, single-sentence title with a conventional fix(trpc) prefix.

Full details: Description check

Explanation

The description explains the bug: only the last entry of tRPC's inputs was used, so chained inputs were missing from the contract and OpenAPI request body. It describes the fix (passing every Standard Schema as inputSchemas), the validation behavior, and the tests. This matches the changed files in to-orpc-router.ts, its test file, and the docs.

  • 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: 96bfa97b-0e07-4ce2-b680-6aead880c317
Commits

Reviewing files that changed from the base of the PR and between ab8311a and d41493d.

Files selected for processing: 3

  • apps/content/docs/integrations/trpc.mdx
  • packages/trpc/src/to-orpc-router.test.ts
  • packages/trpc/src/to-orpc-router.ts

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

@codecov

codecov Bot commented Nov 23, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@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.

✅ No new issues found.

Approach: sound — expose every chained input schema on the converted procedure and let the existing oRPC machinery handle the list, instead of merging schemas inside the adapter.

Reviewed changes — the full 3-file diff at d41493df, plus local verification (pnpm vitest run packages/trpc packages/contract, tsc --noEmit -p packages/trpc, oxlint, oxfmt --check).

  • Every chained input carried over — toORPCProcedure maps each entry of _def.inputs through toStandardSchema and filters, so inputSchemas holds all chained Standard Schemas rather than only .at(-1).
  • Non-standard parsers unchanged — function parsers are still dropped, and an empty result still yields undefined, so procedures without Standard Schema inputs keep their previous shape.
  • Generated spec stays coherent — OpenAPIGenerator.convertSchemas already composes multiple inputSchemas with allOf, and extractJsonObjectSchemaEntries merges allOf branches, so compact path/query/body splitting still works; a path param declared in an earlier input is now found instead of throwing "dynamic param is missing".
  • Docs — one sentence on the integration page states that every chained .input() is carried over and validation stays in tRPC.
  • Tests — two- and three-input chains assert the contract, the generated request body, real calls (success and BAD_REQUEST on a missing field), and skipping a non-standard parser.

The allOf representation is exact here because tRPC's createInputMiddleware validates every parser against getRawInput() and only then merges the parsed objects, so each chained schema constrains the same raw request body.

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

@codspeed

codspeed Bot commented Nov 23, 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/trpc-all-inputs-f4acdc (d41493d) with main (ab8311a)

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 d41493d Commit Preview URL

Branch Preview URL
Nov 23 2026, 09:58 AM

@dinwwwh
dinwwwh merged commit d2eea04 into main Nov 23, 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