Title: Repository resources fetch the wrong content when a file name contains "%" · Issue #3614 · github/github-mcp-server · GitHub
Open Graph Title: Repository resources fetch the wrong content when a file name contains "%" · Issue #3614 · github/github-mcp-server
X Title: Repository resources fetch the wrong content when a file name contains "%" · Issue #3614 · github/github-mcp-server
Description: Describe the bug repo:// resource reads build the raw.githubusercontent.com URL from the decoded file path, so a file name containing % fetches the wrong content. For docs/100%.txt, resources/read on repo://owner/repo/contents/docs/100%2...
Open Graph Description: Describe the bug repo:// resource reads build the raw.githubusercontent.com URL from the decoded file path, so a file name containing % fetches the wrong content. For docs/100%.txt, resources/read ...
X Description: Describe the bug repo:// resource reads build the raw.githubusercontent.com URL from the decoded file path, so a file name containing % fetches the wrong content. For docs/100%.txt, resources/read ...
Opengraph URL: https://github.com/github/github-mcp-server/issues/3614
X: @github
Domain: github.com
IPv4 address: 140.82.113.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Repository resources fetch the wrong content when a file name contains \"%\"","articleBody":"### Describe the bug\r\n\r\n`repo://` resource reads build the raw.githubusercontent.com URL from the *decoded* file path, so a file name containing `%` fetches the wrong content. For `docs/100%.txt`, `resources/read` on `repo://owner/repo/contents/docs/100%25.txt` (the URI `get_file_contents` emits) returns github.com's homepage HTML as the file's text; for a file named `%41.txt` it returns the contents of `A.txt`. Spaces, `#`, `?` and unicode are encoded correctly.\r\n\r\n### Affected version\r\n\r\nmain @ latest-release-9-g84f423e\r\n\r\n### Steps to reproduce the behavior\r\n\r\n```go\r\nc, _ := raw.NewClient(gh, mustParse(\"https://raw.githubusercontent.com/\"))\r\nc.URLFromOpts(nil, \"o\", \"r\", \"100%.txt\") // \"https://raw.githubusercontent.com/\"\r\nc.URLFromOpts(nil, \"o\", \"r\", \"%41.txt\") // \".../o/r/HEAD/%41.txt\", served as A.txt\r\n```\r\n\r\n`https://raw.githubusercontent.com/` redirects (301) to github.com and comes back as 200 `text/html`, which the resource handler treats as a successful text read.\r\n\r\n### Expected vs actual behavior\r\n\r\nExpected: the file named `100%.txt` / `%41.txt` is returned. Actual: GitHub's homepage HTML / the contents of `A.txt`.\r\n\r\n### Root cause and suggested fix\r\n\r\n`pkg/raw/raw.go:95` and `:113` pass decoded path text to `url.URL.JoinPath`, which treats its arguments as already escaped: a literal `%xx` is decoded a second time, and an invalid escape makes `JoinPath` drop its internal error and keep the base URL. `repository_resource.go:192` passes the path already decoded by `uritemplate`.\r\n\r\n`url.PathEscape` each `/`-separated segment of owner/repo/ref/path before `JoinPath` (the `..` rejection stays as is). One existing test, `benign percent-encoded filename allowed`, expects `%2ehidden` to pass through unescaped, which actually requests `.hidden`; with the fix it becomes `%252ehidden`. I have a patch with regression tests (raw URL cases and a `resources/read` handler test) and can open a PR if the approach sounds right. Related: #3437.\r\n","author":{"url":"https://github.com/jaeminbird","@type":"Person","name":"jaeminbird"},"datePublished":"2026-10-29T08:34:58Z","url":"https://github.com/github/github-mcp-server/issues/3614"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:36e58aa6-febe-1c02-b984-9a816bdf833c |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 80EC:3E2BB7:8DA635:C5CA25:6B05CBCA |
| html-safe-nonce | e63ca5550d336c69f7530a05a4b68c36e841c25b12df882ccf3b701af141bba8 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4MEVDOjNFMkJCNzo4REE2MzU6QzVDQTI1OjZCMDVDQkNBIiwidmlzaXRvcl9pZCI6IjIyOTkzODQ2NzI5ODEyMDgwMTEiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | d5d1ec762c9e91a19f52e07470927e246157293dc9c86906a2f0c77db5b6152f |
| hovercard-subject-tag | issue:6095969426 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/github/github-mcp-server/3614/issue_layout |
| twitter:image | https://opengraph.githubassets.com/f32e5f9a730361ff5c96287184b2f017f074b170b86b8cd9227deb66de14ef62/github/github-mcp-server/issues/3614 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/f32e5f9a730361ff5c96287184b2f017f074b170b86b8cd9227deb66de14ef62/github/github-mcp-server/issues/3614 |
| og:image:alt | Describe the bug repo:// resource reads build the raw.githubusercontent.com URL from the decoded file path, so a file name containing % fetches the wrong content. For docs/100%.txt, resources/read ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jaeminbird |
| hostname | github.com |
| expected-hostname | github.com |
| None | 08d6d51500e13cdaf71a9aad37c03e883f1143f9325056e77a14fa0d06d5bf64 |
| turbo-cache-control | no-preview |
| go-import | github.com/github/github-mcp-server git https://github.com/github/github-mcp-server.git |
| octolytics-dimension-user_id | 9919 |
| octolytics-dimension-user_login | github |
| octolytics-dimension-repository_id | 942771284 |
| octolytics-dimension-repository_nwo | github/github-mcp-server |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 942771284 |
| octolytics-dimension-repository_network_root_nwo | github/github-mcp-server |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 839b69d5acfb3181bc844f20b9848f74b957add3 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
| Server | github.com |
| Content-Type | text/html; charset=utf-8 |
| Cache-Control | max-age=0, private, must-revalidate |
Viewport: width=device-width