Skip to content

Conversation

@unnoq
Copy link
Member

@unnoq unnoq commented Nov 3, 2025

Closes: #602

Summary by CodeRabbit

  • Documentation

    • Added a new guide explaining how to disable output validation in procedures, with configuration examples, limitations, and usage scenarios.
  • Tests

    • Added test coverage verifying that output validation can be disabled and that procedures return raw handler results when disabled.

@dosubot dosubot bot added the size:M This PR changes 30-99 lines, ignoring generated files. label Nov 3, 2025
@vercel
Copy link

vercel bot commented Nov 3, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
orpc Ready Ready Preview Comment Nov 3, 2025 1:48pm

@coderabbitai
Copy link

coderabbitai bot commented Nov 3, 2025

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

Walkthrough

Adds documentation and a sidebar entry for "Disabling Output Validation" and a test that verifies output validation can be disabled by setting initialOutputValidationIndex to NaN. No runtime code changes beyond docs/config and tests.

Changes

Cohort / File(s) Summary
Docs & Site config
apps/content/.vitepress/config.ts, apps/content/docs/openapi/advanced/disabling-output-validation.md
Adds a new OpenAPI Advanced doc page and a sidebar entry linking to /docs/openapi/advanced/disabling-output-validation. The markdown explains using initialOutputValidationIndex = NaN, shows examples, and notes limitations.
Tests
packages/server/tests/advanced.test.ts
Adds a test that constructs a procedure with initialOutputValidationIndex = NaN, confirms a handler returning a mismatched type is returned unchanged (output validation skipped).

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Procedure
    participant Validator as Output Validator

    rect rgb(200,230,255)
    Note over Procedure,Validator: Validation enabled (normal flow)
    Client->>Procedure: invoke()
    Procedure->>Validator: validate(output)
    Validator-->>Procedure: pass/fail
    Procedure-->>Client: return result
    end

    rect rgb(240,230,200)
    Note over Procedure: Validation disabled (initialOutputValidationIndex = NaN)
    Client->>Procedure: invoke()
    Procedure->>Procedure: skip validation
    Procedure-->>Client: return raw result
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

  • Files to check closely:
    • apps/content/.vitepress/config.ts — ensure sidebar entry placement and link path are correct.
    • apps/content/docs/openapi/advanced/disabling-output-validation.md — verify examples and wording accurately reflect behavior and limitations.
    • packages/server/tests/advanced.test.ts — confirm test setup uses NaN correctly and assertions reflect intended behavior.

Suggested labels

lgtm

Poem

🐇 I hopped through docs and tests today,

NaN says "skip" — validations stray.
Big payloads dance, light on their feet,
A rabbit's cheer for faster meat.

Pre-merge checks and finishing touches

✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title 'docs: add guide for disabling output validation' accurately describes the main change in the changeset. The PR adds comprehensive documentation (a markdown guide and test file) for the new feature that allows disabling output validation in oRPC procedures, plus corresponding sidebar navigation updates. The title is concise, specific, and clearly communicates the primary contribution.
Linked Issues check ✅ Passed The pull request successfully addresses issue #602's core requirement by implementing and documenting a mechanism to disable output validation. The PR adds a new documentation file explaining how to set initialOutputValidationIndex to NaN to bypass validation, includes a working test demonstrating the feature, and updates the sidebar navigation for discoverability. This directly fulfills the feature request to provide a way to disable output validation for performance improvement.
Out of Scope Changes check ✅ Passed All changes in this pull request are directly aligned with the linked issue #602. The modifications include: (1) documentation explaining the disable-validation feature, (2) a sidebar entry for discoverability, and (3) a test file validating the feature works as expected. Each change supports the primary objective of documenting and validating the output validation disabling capability. No unrelated or out-of-scope changes are present.
✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch unnoq/issue602

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 996096f and cd81352.

📒 Files selected for processing (1)
  • apps/content/docs/openapi/advanced/disabling-output-validation.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/content/docs/openapi/advanced/disabling-output-validation.md
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: publish-commit
  • GitHub Check: lint
  • GitHub Check: test

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @unnoq, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request enhances the documentation by providing a new guide on how to disable output validation in oRPC procedures. This is particularly useful for scenarios where output schemas are primarily used for OpenAPI specification generation, allowing for performance improvements by skipping runtime validation. The changes include adding the new documentation page, updating the navigation, and introducing a corresponding test case to confirm the feature's behavior.

Highlights

  • New Documentation Guide: A new guide has been added explaining how to disable output validation in oRPC procedures.
  • Performance Improvement: The guide details how to improve performance by disabling validation when output schemas are only for OpenAPI specification generation.
  • Configuration Method: It introduces the use of "initialOutputValidationIndex: Number.NaN" in the "$config" method to achieve this.
  • New Test Case: A test has been added to "packages/server/tests/advanced.test.ts" to verify the functionality of disabling output validation.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@codecov
Copy link

codecov bot commented Nov 3, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request adds documentation for disabling output validation. The documentation is clear and correctly highlights the limitations. The added test confirms the feature works. I've suggested an improvement to the test file to also cover the default behavior (when validation is enabled), which will make the test suite more robust and self-contained. Overall, a good addition to the project.

Comment on lines +1 to +20
import z from 'zod'
import { os } from '../src'

it('support disable output validation by setting initialOutputValidationIndex to NaN', async () => {
// docs: apps/content/docs/openapi/advanced/disabling-output-validation.md

const procedure = os.$config({
initialOutputValidationIndex: Number.NaN,
})
.use(({ next }) => next())
.output(z.number())
.use(({ next }) => next())
// @ts-expect-error invalid output type
.handler(() => {
return 'invalid'
})
.callable()

await expect(procedure()).resolves.toBe('invalid')
})
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

While the added test correctly verifies that output validation can be disabled, it would be beneficial to also include a test case that confirms the default behavior (i.e., that validation is enabled and throws an error for invalid output). This would make the test suite for this feature more complete and robust. I'd suggest wrapping both tests in a describe block for better organization.

import z from 'zod'
import { os } from '../src'

describe('output validation', () => {
  it('is enabled by default and throws on invalid output', async () => {
    const procedure = os
      .output(z.number())
      // @ts-expect-error invalid output type
      .handler(() => {
        return 'invalid'
      })
      .callable()

    await expect(procedure()).rejects.toThrow(z.ZodError)
  })

  it('can be disabled by setting initialOutputValidationIndex to NaN', async () => {
    // docs: apps/content/docs/openapi/advanced/disabling-output-validation.md

    const procedure = os.$config({
      initialOutputValidationIndex: Number.NaN,
    })
      .use(({ next }) => next())
      .output(z.number())
      .use(({ next }) => next())
      // @ts-expect-error invalid output type
      .handler(() => {
        return 'invalid'
      })
      .callable()

    await expect(procedure()).resolves.toBe('invalid')
  })
})

@pkg-pr-new
Copy link

pkg-pr-new bot commented Nov 3, 2025

More templates

@orpc/ai-sdk

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

@orpc/arktype

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

@orpc/client

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

@orpc/contract

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

@orpc/experimental-durable-iterator

npm i https://pkg.pr.new/@orpc/experimental-durable-iterator@1163

@orpc/hey-api

npm i https://pkg.pr.new/@orpc/hey-api@1163

@orpc/interop

npm i https://pkg.pr.new/@orpc/interop@1163

@orpc/json-schema

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

@orpc/nest

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

@orpc/openapi

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

@orpc/openapi-client

npm i https://pkg.pr.new/@orpc/openapi-client@1163

@orpc/otel

npm i https://pkg.pr.new/@orpc/otel@1163

@orpc/experimental-publisher

npm i https://pkg.pr.new/@orpc/experimental-publisher@1163

@orpc/react

npm i https://pkg.pr.new/@orpc/react@1163

@orpc/react-query

npm i https://pkg.pr.new/@orpc/react-query@1163

@orpc/experimental-react-swr

npm i https://pkg.pr.new/@orpc/experimental-react-swr@1163

@orpc/server

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

@orpc/shared

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

@orpc/solid-query

npm i https://pkg.pr.new/@orpc/solid-query@1163

@orpc/standard-server

npm i https://pkg.pr.new/@orpc/standard-server@1163

@orpc/standard-server-aws-lambda

npm i https://pkg.pr.new/@orpc/standard-server-aws-lambda@1163

@orpc/standard-server-fastify

npm i https://pkg.pr.new/@orpc/standard-server-fastify@1163

@orpc/standard-server-fetch

npm i https://pkg.pr.new/@orpc/standard-server-fetch@1163

@orpc/standard-server-node

npm i https://pkg.pr.new/@orpc/standard-server-node@1163

@orpc/standard-server-peer

npm i https://pkg.pr.new/@orpc/standard-server-peer@1163

@orpc/svelte-query

npm i https://pkg.pr.new/@orpc/svelte-query@1163

@orpc/tanstack-query

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

@orpc/trpc

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

@orpc/valibot

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

@orpc/vue-colada

npm i https://pkg.pr.new/@orpc/vue-colada@1163

@orpc/vue-query

npm i https://pkg.pr.new/@orpc/vue-query@1163

@orpc/zod

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

commit: cd81352

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (2)
apps/content/docs/openapi/advanced/disabling-output-validation.md (1)

25-48: Consider expanding the limitation section.

The transform example is excellent, but the limitation section could be more comprehensive. When validation is disabled, other schema features are also skipped, including:

  • Refinements (.refine(), .superRefine())
  • Default values (.default())
  • Coercions and preprocessing
  • Any other schema-level data modifications

Consider adding a note that all validation and transformation logic is bypassed, not just explicit .transform() calls.

Apply this diff to add a more comprehensive note:

 ## Limitation
 
-This approach will not work correctly if your schema transforms the data into a different type during validation.
+This approach will not work correctly if your schema performs any transformations or modifications during validation, including:
+
+- Transforms (`.transform()`)
+- Refinements (`.refine()`, `.superRefine()`)
+- Default values (`.default()`)
+- Coercions and preprocessing
 
 ```ts twoslash
packages/server/tests/advanced.test.ts (1)

4-20: LGTM! Test correctly verifies the feature.

The test properly validates that setting initialOutputValidationIndex to NaN disables output validation, allowing the string 'invalid' to pass through despite the z.number() output schema.

Consider adding a test case for the transform limitation mentioned in the documentation:

it('demonstrates transform limitation when output validation is disabled', async () => {
  const procedure = os.$config({
    initialOutputValidationIndex: Number.NaN,
  })
    .output(z.object({ value: z.number().transform(val => String(val)) }))
    .handler(() => {
      return { value: 123 }
    })
    .callable()

  const result = await procedure()
  
  // With validation disabled, transform is skipped
  // Client expects string but receives number
  expect(result.value).toBe(123) // number, not "123" string
  expect(typeof result.value).toBe('number')
})

This would help verify the documented limitation and ensure the behavior is well-understood.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 5c38c37 and 996096f.

📒 Files selected for processing (3)
  • apps/content/.vitepress/config.ts (1 hunks)
  • apps/content/docs/openapi/advanced/disabling-output-validation.md (1 hunks)
  • packages/server/tests/advanced.test.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/server/tests/advanced.test.ts (1)
packages/server/src/builder.ts (1)
  • os (336-352)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
  • GitHub Check: publish-commit
  • GitHub Check: test
  • GitHub Check: lint
  • GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (3)
apps/content/.vitepress/config.ts (1)

287-287: LGTM! Sidebar entry correctly configured.

The navigation link is properly placed in the Advanced section and matches the new documentation file path.

apps/content/docs/openapi/advanced/disabling-output-validation.md (2)

1-8: LGTM! Clear and concise introduction.

The frontmatter and introduction effectively explain the feature's purpose and when to use it.


10-23: LGTM! Configuration example is clear.

The example demonstrates the correct usage of initialOutputValidationIndex: Number.NaN and explains that all procedures built from the base will inherit this behavior.

@unnoq unnoq merged commit 29608ff into main Nov 3, 2025
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M This PR changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Disable output validation for better performance

1 participant