fix(repos): return a resource link for files over 1 MB in get_file_contents - #3419
Open
jayhemnani9910 wants to merge 1 commit into
Open
jayhemnani9910 wants to merge 1 commit into
jayhemnani9910 wants to merge 1 commit into
Conversation
…ntents The Contents API returns files over 1 MB with an empty content field and encoding "none". Since the symlink read checks, get_file_contents tried to decode that content and failed with "unsupported content encoding: none" before reaching the large-file branch. Treat that response as content not available so the tool returns the resource link again.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_file_contentserrors on every file of 1 MB or more since v1.10.0. This treats the Contents API'sencoding: "none"response as "content not returned", so the existing large-file resource link is returned again.Why
Fixes #3417
The Contents API returns files over 1 MB with
"content": ""and"encoding": "none".repositoryContentBytescalledGetContent()on that and failed withunsupported content encoding: nonebefore thefileSize >= maxContentSizebranch ran.What changed
repositoryContentBytes: anencoding: "none"response is handled like a missingcontentfield.Test_GetFileContents_ContentlessRequestCountsusing the real API response shape (content: "",encoding: "none"). It fails without the fix.MCP impact
get_file_contentsreturns the "too large to display" message and resource link for files over 1 MB again, as in v1.9.0. No schema change.Prompts tested (tool changes only)
Security / limits
Tool renaming
deprecated_tool_aliases.goLint & tests
./script/lintpins, andgofmt -l: clean)go test ./...(30 packages ok, same as main)Ran against the real API with v1.14.0 and with this branch: a 1.5 MB PNG and a 5 MB C header both error on v1.14.0 and return the resource link with this change. Small files and symlinked files are unchanged.
Docs