Title: list_label silently turns perPage=0 into 100 although the schema advertises minimum: 1 · Issue #3647 · github/github-mcp-server · GitHub
Open Graph Title: list_label silently turns perPage=0 into 100 although the schema advertises minimum: 1 · Issue #3647 · github/github-mcp-server
X Title: list_label silently turns perPage=0 into 100 although the schema advertises minimum: 1 · Issue #3647 · github/github-mcp-server
Description: Describe the bug list_label advertises perPage with minimum: 1 and maximum: 100, but a request that sends perPage: 0 is accepted and silently replaced by the server default of 100. The value is never validated against the range the tool ...
Open Graph Description: Describe the bug list_label advertises perPage with minimum: 1 and maximum: 100, but a request that sends perPage: 0 is accepted and silently replaced by the server default of 100. The value is nev...
X Description: Describe the bug list_label advertises perPage with minimum: 1 and maximum: 100, but a request that sends perPage: 0 is accepted and silently replaced by the server default of 100. The value is nev...
Opengraph URL: https://github.com/github/github-mcp-server/issues/3647
X: @github
Domain: github.com
IPv4 address: 140.82.114.4
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"list_label silently turns perPage=0 into 100 although the schema advertises minimum: 1","articleBody":"\u003c!-- github-mcp-server issue template: bug_report.md -->\n\n### Describe the bug\n\n`list_label` advertises `perPage` with `minimum: 1` and `maximum: 100`, but a request that sends `perPage: 0` is accepted and silently replaced by the server default of `100`. The value is never validated against the range the tool publishes, so an out-of-domain argument produces a successful response with a page size the caller did not ask for.\n\n### Affected version\n\n`2.x`, commit `e3809fe91c7546633241006bf0b91f23b2595e28` (`Add cursor pagination to list_label (#3505)`), tested on `windows/amd64` with Go 1.27.3.\n\n### Steps to reproduce the behavior\n\n1. Add the test below to `pkg/github`.\n2. Run `go test ./pkg/github -run TestListLabelPerPageZero -v`.\n3. The test passes — that is the bug: `0` is out of the advertised domain, and it is neither rejected nor reported.\n\n```go\npackage github\n\nimport \"testing\"\n\nfunc TestListLabelPerPageZero(t *testing.T) {\n\t// This is the call list_label makes at labels.go:180.\n\tgot, err := OptionalIntParamWithDefault(\n\t\tmap[string]any{\"perPage\": float64(0)},\n\t\t\"perPage\",\n\t\tlistLabelsDefaultPerPage,\n\t)\n\tif err != nil {\n\t\tt.Fatalf(\"perPage=0 was rejected with %v\", err)\n\t}\n\tif got != listLabelsDefaultPerPage {\n\t\tt.Fatalf(\"perPage=0 resolved to %d\", got)\n\t}\n\tt.Logf(\"perPage=0 was silently replaced by the default %d\", got)\n}\n```\n\n### Expected vs actual behavior\n\n**Actual behavior:** `perPage=0` and \"argument omitted\" are indistinguishable to the handler, so an explicit `0` returns `100` labels instead of an error. The response carries no indication that the requested value was replaced. Related: `perPage=101` also passes the parsing stage and is rejected later by `CursorPaginationParams.ToGraphQLParams` with a different error (`perPage value 101 exceeds maximum of 100`), so the two ends of the range travel through unrelated code paths.\n\n**Expected behavior:** a `perPage` outside `1..100` should be rejected with an argument error at the point the parameter is read — the same way `101` already is — rather than being silently coerced.\n\n### Logs\n\n```\nargs=map[perPage:0] -> perPage=100 err=\u003cnil>\nargs=map[perPage:1] -> perPage=1 err=\u003cnil>\nargs=map[perPage:100] -> perPage=100 err=\u003cnil>\nargs=map[perPage:101] -> perPage=101 err=\u003cnil> (rejected later by ToGraphQLParams)\nargs=map[] -> perPage=100 err=\u003cnil>\n```\n\n---\n\n## Root cause\n\n```go\n// pkg/github/params.go:236\nfunc OptionalIntParamWithDefault(args map[string]any, p string, d int) (int, error) {\n\tv, err := OptionalIntParam(args, p)\n\tif err != nil {\n\t\treturn 0, err\n\t}\n\tif v == 0 { // zero value, not \"key absent\"\n\t\treturn d, nil\n\t}\n\treturn v, nil\n}\n```\n\nThe helper conflates \"the caller sent `0`\" with \"the caller sent nothing\". Its boolean sibling two functions below, `OptionalBoolParamWithDefault`, checks presence instead. `CursorPaginationParams.ToGraphQLParams` already validates both ends:\n\n```go\nif p.PerPage > 100 {\n\treturn nil, fmt.Errorf(\"perPage value %d exceeds maximum of 100\", p.PerPage)\n}\nif p.PerPage \u003c 0 {\n\treturn nil, fmt.Errorf(\"perPage value %d cannot be negative\", p.PerPage)\n}\n```\n\n`0` satisfies neither branch and is consumed by the defaulting helper before the validator sees it.\n\nThe same PR's table test makes the gap explicit — `pkg/github/labels_test.go:209-219` contains:\n\n```go\n{\n\tname: \"rejects a page size above 100\",\n\trequestArgs: map[string]any{\"owner\": \"owner\", \"repo\": \"repo\", \"perPage\": float64(101)},\n\texpectToolError: true,\n\texpectedToolErrMsg: \"perPage value 101 exceeds maximum of 100\",\n},\n```\n\nso the upper bound was deliberately enforced and tested, while the lower bound has no case and never reaches `ToGraphQLParams`.\n\n## Suggested fix\n\nMake the default depend on key presence and validate the range:\n\n```go\nperPage := listLabelsDefaultPerPage\nif _, present := args[\"perPage\"]; present {\n\tv, err := OptionalIntParam(args, \"perPage\")\n\tif err != nil {\n\t\treturn utils.NewToolResultError(err.Error()), nil, nil\n\t}\n\tif v \u003c 1 || v > 100 {\n\t\treturn utils.NewToolResultError(\n\t\t\tfmt.Sprintf(\"perPage must be between 1 and 100, got %d\", v)), nil, nil\n\t}\n\tperPage = v\n}\n```\n\nor, more generally, change `OptionalIntParamWithDefault` to check presence the way `OptionalBoolParamWithDefault` does and let `ToGraphQLParams` do the range check. The second option changes behaviour for every tool that uses the helper, so it probably wants its own issue; the first keeps the change scoped to `list_label`.\n","author":{"url":"https://github.com/soarkit","@type":"Person","name":"soarkit"},"datePublished":"2026-11-01T15:25:03Z","url":"https://github.com/github/github-mcp-server/issues/3647"}
| 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:02e9e435-a960-e48a-bfb3-fd3bf7ddafa6 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B8D8:392ED4:1B8A9C:26D2F6:6B06B939 |
| html-safe-nonce | 4d10a9c90162871f03902bbd68999026addb54d6f4ec5f70e2d3c489a34f938c |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOEQ4OjM5MkVENDoxQjhBOUM6MjZEMkY2OjZCMDZCOTM5IiwidmlzaXRvcl9pZCI6IjExODQ4MzQwMjgyMzk3NjM3NjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 4cf7d7b3cb697c07fafd2b69b62251410fe28cd6e6d179afac99cf6b460a6160 |
| hovercard-subject-tag | issue:6148618977 |
| 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/3647/issue_layout |
| twitter:image | https://opengraph.githubassets.com/cf5986bc2e5457f458802b615f733651a5a7c95dfcf50e7d977253378963bdfb/github/github-mcp-server/issues/3647 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/cf5986bc2e5457f458802b615f733651a5a7c95dfcf50e7d977253378963bdfb/github/github-mcp-server/issues/3647 |
| og:image:alt | Describe the bug list_label advertises perPage with minimum: 1 and maximum: 100, but a request that sends perPage: 0 is accepted and silently replaced by the server default of 100. The value is nev... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | soarkit |
| hostname | github.com |
| expected-hostname | github.com |
| None | 32031aaff792fa7ad778f7418e1fbfc0d525a5779804329b769aa75230448a18 |
| 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 | 37014d914b7d14eede971655595f687a0202af40 |
| 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