Skip to content

Conversation

@w3nl
Copy link
Contributor

@w3nl w3nl commented Feb 6, 2026

Allows disabling response validation by introducing a validateResponse option.

This provides flexibility for situations where response validation is not required or desired, such as during development or in performance-critical scenarios.

Response validation is enabled by default.

Summary by CodeRabbit

Release Notes

  • New Features

    • Introduced a validateResponse configuration option for API setup to control response validation behavior. Response validation is enabled by default; users can disable it when needed.
  • Tests

    • Added test coverage for validateResponse configuration parameter handling in different states.

Allows disabling response validation by introducing a `validateResponse` option.

This provides flexibility for situations where response validation is not required or desired, such as during development or in performance-critical scenarios.

Response validation is enabled by default.
@w3nl w3nl requested a review from Copilot February 6, 2026 10:35
@coderabbitai
Copy link

coderabbitai bot commented Feb 6, 2026

📝 Walkthrough

Walkthrough

This pull request introduces a new validateResponse configuration option to the API that conditionally controls whether response validation occurs. The flag defaults to true, is propagated through the API constructor and setup flow, and determines whether the postResponseHandler is registered during router initialization.

Changes

Cohort / File(s) Summary
API Configuration
src/api.js
Added validateResponse boolean property to Api schema with default value true; extended constructor signature and propagated to router setup.
Router Implementation
src/router.js
Added validateResponse parameter to setupRouter (default true); refactored handler registration to conditionally include postResponseHandler based on the flag.
Test Coverage
src/router.test.js
Added test cases validating postResponseHandler registration behavior across three scenarios: when validateResponse is false, true, and not specified (default).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

  • Fix the AJV validator #414: Modifies router setup behavior for response validation and postResponseHandler registration, directly overlapping with the router implementation changes in this PR.
  • Log response validation errors #378: Changes how the postResponseHandler is created and registered in router.js, related to the conditional handler registration logic introduced here.

Poem

🐰 A toggle here, a flag so neat,
Response validation, optional treat!
When true, the handler hops in place,
When false, it fades without a trace. ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: introducing a configurable option to disable response validation, which is the primary feature across all modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/optional-response-validation

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.

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds a validateResponse configuration option to allow disabling response validation when needed. Response validation is enabled by default to maintain backward compatibility. The feature provides flexibility for development or performance-critical scenarios where response validation overhead is not desired.

Changes:

  • Added validateResponse boolean option to the Api class and setupRouter function with a default value of true
  • Modified router to conditionally register the postResponseHandler based on the validateResponse flag
  • Added comprehensive test coverage for all three scenarios: explicitly disabled, explicitly enabled, and default behavior

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
src/api.js Added validateResponse property to the Api class with JSDoc documentation, constructor parameter handling, and pass-through to setupRouter
src/router.js Added validateResponse parameter with default value true and conditional registration of postResponseHandler based on the flag
src/router.test.js Added three test cases covering validateResponse=false, validateResponse=true, and default behavior

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@w3nl w3nl merged commit 048c19c into main Feb 6, 2026
18 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.

2 participants