Skip to content

fix(mcpx/openapi): refuse specs and call responses past the 32MiB cap (#8271) - #10949

Merged
dezren39 merged 1 commit into
mainfrom
queue/18622-8271-spec-cap
Nov 17, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/18622-8271-spec-cap

Conversation

@dezren39

@dezren39 dezren39 commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

Fixes #8271

Contract decision 2 (#4375) requires a buffered success body to be refused past its named cap, never silently truncated. Both peer reads in internal/openapi used io.ReadAll(io.LimitReader(resp.Body, 32<<20)) and truncated:

  • Load — a fetched OpenAPI document: a truncated spec parsed as a shorter document or failed downstream with a misleading error.
  • API.Call — a tool call's response body: a truncated result was delivered as if whole.

Fix, following the provider paths' cap+1 pattern (internal/model/openai.go):

  • The cap is named in internal/defaults as the recorded constant OpenAPISpecBodyLimit (32 MiB), with the contract rationale in its comment.
  • Both sites read cap+1 and fail with a clear "exceeds the 33554432-byte limit" error when the extra byte exists.
  • The os.ReadFile local-path branch beside the fetch is untouched — not peer bytes, per the issue's scope note.

Tests (oracle: #4375 contract decision 2 — over-cap is a fetch/call failure at the cap, and exactly-at-cap is not over-cap):

  • TestLoadRefusesASpecPastTheCap — cap+1 spec fails the fetch with an "exceeds" error.
  • TestLoadReadsASpecAtExactlyTheCap — an exactly-at-cap body is read whole (fails as the invalid document it is, not as over-cap).
  • TestCallRefusesAResponsePastTheCap — cap+1 response fails the call with an "exceeds" error.
  • Full internal/openapi package passes on the laptop worktree; gofmt clean.

Pre-existing failure, not from this change: internal/defaults' TestNoPackageRedeclaresADefault fails identically on clean main (it flags internal/elicit/presence.go's DefaultAudienceWindow). The new constant lives in internal/defaults itself and is not flagged; the elicit violation is left for its own follow-up.

Queue task 18622 (lane any-m).


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…2MiB cap instead of truncating (#8271)

Contract decision 2 (#4375) requires a buffered success body to be refused past its named cap, never silently truncated; both openapi peer reads used io.LimitReader at 32MiB and truncated. The cap is now named as defaults.OpenAPISpecBodyLimit (a defaults constant, per the issue's recorded form) and both sites read cap+1 and fail with a clear exceeds error: Load (fetched spec) and API.Call (tool-call response). The os.ReadFile local-path branch is untouched (not peer bytes). Tests: over-cap refusal at both sites plus the exactly-at-cap boundary (read whole, fails as parse, not as over-cap). Note: internal/defaults TestNoPackageRedeclaresADefault fails identically on clean main (pre-existing elicit/presence.go violation) — untouched by this change; the new constant lives in internal/defaults itself and is not flagged.
@dezren39
dezren39 requested a review from a team as a code owner November 17, 2026 03:57
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-17T03:57:58.120389Z
We couldn’t complete this review. Comment @codex review to try again.
f558e5b PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@coderabbitai

coderabbitai Bot commented Nov 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 18 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3802b6fc-0c56-44e2-99fc-8fd064128176
Commits

Reviewing files that changed from the base of the PR and between bc94fb3 and f558e5b.

Files selected for processing: 3

  • pkgs/mcpx/internal/defaults/defaults.go
  • pkgs/mcpx/internal/openapi/openapi.go
  • pkgs/mcpx/internal/openapi/openapi_test.go
  • 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

@dezren39
dezren39 merged commit 45a2314 into main Nov 17, 2026
1 check passed
@dezren39
dezren39 deleted the queue/18622-8271-spec-cap branch November 17, 2026 03:59
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.

mcpx(openapi): spec fetch truncates silently at 32MiB instead of refusing past the cap (#4375 contract decision 2)

1 participant