Repository navigation
fix(mcpx/openapi): refuse specs and call responses past the 32MiB cap (#8271) - #10949
Conversation
…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.
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Warning Review limit reachedYou'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. View limit details
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. |
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/openapiusedio.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):internal/defaultsas the recorded constantOpenAPISpecBodyLimit(32 MiB), with the contract rationale in its comment.os.ReadFilelocal-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.internal/openapipackage passes on the laptop worktree;gofmtclean.Pre-existing failure, not from this change:
internal/defaults'TestNoPackageRedeclaresADefaultfails identically on clean main (it flagsinternal/elicit/presence.go'sDefaultAudienceWindow). The new constant lives ininternal/defaultsitself and is not flagged; the elicit violation is left for its own follow-up.Queue task 18622 (lane any-m).
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.