Skip to content

fix: rm redundant pullResponseExamples call from Endpoint::outputSchema#3345

Merged
RobinTail merged 3 commits intomasterfrom
fix/output-schema-performance
Apr 24, 2026
Merged

fix: rm redundant pullResponseExamples call from Endpoint::outputSchema#3345
RobinTail merged 3 commits intomasterfrom
fix/output-schema-performance

Conversation

@RobinTail
Copy link
Copy Markdown
Owner

@RobinTail RobinTail commented Apr 24, 2026

Performance regression since v24.0.0 - the outputSchema getter was calling the expensive pullResponseExamples() operation on first access (R.once protected), even though examples are only needed for OpenAPI documentation generation (getResponses).

This fixes the issue where simply accessing the output schema for runtime validation was unnecessarily triggering example generation.

first introduced by #2666
merged by #2546
found this during my work on #3344

Summary by CodeRabbit

  • Bug Fixes

    • Improved request performance by deferring output schema example processing; examples are now generated only when needed for documentation/OpenAPI workflows, not during initial request handling.
  • Documentation

    • Added changelog entry v27.2.4 documenting the change in example processing behavior.

…etter

Performance regression since v24.4.0 - the outputSchema getter was calling
the expensive pullResponseExamples() operation on every access, even though
examples are only needed for OpenAPI documentation generation (getResponses).

This fixes the issue where simply accessing the output schema for runtime
validation was unnecessarily triggering example generation.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc91afcb-fd26-4309-bbba-13f229a41b55

📥 Commits

Reviewing files that changed from the base of the PR and between 77d16b5 and 6d8ac7e.

📒 Files selected for processing (1)
  • CHANGELOG.md
✅ Files skipped from review due to trivial changes (1)
  • CHANGELOG.md

📝 Walkthrough

Walkthrough

Removed eager population of output schema examples from the endpoint getter and documented this change in the changelog v27.2.4; example processing is now limited to documentation/OpenAPI generator workflows and specific control paths.

Changes

Cohort / File(s) Summary
Documentation
CHANGELOG.md
Added v27.2.4 entry explaining that output schema examples are no longer processed during initial API request handling and are restricted to docs/OpenAPI generator workflows.
Core Logic
express-zod-api/src/endpoint.ts
Deleted the #ensureOutputExamples() call from the outputSchema getter, deferring example materialization to other control paths (e.g., response generation).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • #2842: Adjusts how output examples are sourced and populated across the codebase, directly related to removing eager example initialization.
  • #2741: Modifies example sourcing/checking behavior within the #ensureOutputExamples logic referenced by this change.

Suggested labels

enhancement

Poem

🐰 A nibble, a hop, examples wait in line,

No rush at the gate, they’ll shine when it’s time.
Deferred with a twitch and a curious stare,
Lazy-loaded joy floats light on the air.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately describes the main change: removing a redundant call to pullResponseExamples from the outputSchema getter to fix a performance regression.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/output-schema-performance

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.

Comment thread CHANGELOG.md Outdated
@RobinTail RobinTail force-pushed the fix/output-schema-performance branch from 488f554 to 536188e Compare April 24, 2026 11:41
@coveralls-official
Copy link
Copy Markdown

coveralls-official Bot commented Apr 24, 2026

Coverage Status

Coverage is 100.0%fix/output-schema-performance into master. No base build found for master.

…etter

Performance regression since v24.0.0 - the outputSchema getter was calling
the expensive pullResponseExamples() operation on every access, even though
examples are only needed for OpenAPI documentation generation (getResponses).

This fixes the issue where simply accessing the output schema for runtime
validation was unnecessarily triggering example generation.
@RobinTail RobinTail force-pushed the fix/output-schema-performance branch from 536188e to 77d16b5 Compare April 24, 2026 11:48
@RobinTail RobinTail marked this pull request as ready for review April 24, 2026 11:51
@pullfrog
Copy link
Copy Markdown
Contributor

pullfrog Bot commented Apr 24, 2026

Reviewed PR #3345 — approved with no issues. The removal of #ensureOutputExamples() from the outputSchema getter is correct since getResponses("positive") already calls it, and that's the only code path where examples are needed.

Task list (5/5 completed)
  • Read the diff to understand the changes
  • Investigate the removed code and its context in endpoint.ts
  • Verify pullResponseExamples is still called where needed
  • Check CHANGELOG entry
  • Submit review

Pullfrog  | View workflow run | via Pullfrog | Using Claude Opus𝕏

Copy link
Copy Markdown
Contributor

@pullfrog pullfrog Bot left a comment

Choose a reason for hiding this comment

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

Reviewed — no issues found.

The removal is correct: #ensureOutputExamples() is already called at the right place in getResponses("positive") (line 176), which is the only code path that needs examples (both Documentation and Integration generators access output schemas exclusively through getResponses, never the outputSchema getter). The outputSchema getter is @internal and only accessed externally by Diagnostics (at startup, non-production) and test code — neither of which need examples on the schema.

Task list (5/5 completed)
  • Read the diff to understand the changes
  • Investigate the removed code and its context in endpoint.ts
  • Verify pullResponseExamples is still called where needed
  • Check CHANGELOG entry
  • Submit review

Pullfrog  | View workflow run | Using Claude Opus𝕏

@RobinTail RobinTail merged commit 95f0c74 into master Apr 24, 2026
13 checks passed
@RobinTail RobinTail deleted the fix/output-schema-performance branch April 24, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant