{"record":{"id":"8861d1c8ff343563","repo":"github/github-mcp-server","slug":"parameter-s-is-not-a-valid-number-w","errorCode":null,"errorMessage":"parameter %s is not a valid number: %w","messagePattern":"parameter (.+?) is not a valid number: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/params.go","lineNumber":162,"sourceCode":"\t}\n\n\treturn val, nil\n}\n\n// RequiredInt is a helper function that can be used to fetch a requested parameter from the request.\n// It does the following checks:\n// 1. Checks if the parameter is present in the request.\n// 2. Checks if the parameter is of the expected type (float64 or numeric string).\n// 3. Checks if the parameter is not empty, i.e: non-zero value\nfunc RequiredInt(args map[string]any, p string) (int, error) {\n\tv, ok := args[p]\n\tif !ok {\n\t\treturn 0, fmt.Errorf(\"missing required parameter: %s\", p)\n\t}\n\n\tresult, err := toInt(v)\n\tif err != nil {\n\t\treturn 0, fmt.Errorf(\"parameter %s is not a valid number: %w\", p, err)\n\t}\n\n\tif result == 0 {\n\t\treturn 0, fmt.Errorf(\"missing required parameter: %s\", p)\n\t}\n\n\treturn result, nil\n}\n\n// RequiredBigInt is a helper function that can be used to fetch a requested parameter from the request.\n// It does the following checks:\n// 1. Checks if the parameter is present in the request.\n// 2. Checks if the parameter is of the expected type (float64 or numeric string).\n// 3. Checks if the parameter is not empty, i.e: non-zero value.\n// 4. Validates that the float64 value can be safely converted to int64 without truncation.\nfunc RequiredBigInt(args map[string]any, p string) (int64, error) {\n\tval, ok := args[p]\n\tif !ok {","sourceCodeStart":144,"sourceCodeEnd":180,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/params.go#L144-L180","documentation":"Thrown by RequiredInt in pkg/github/params.go when an int-typed required argument is present but toInt cannot coerce it: unparseable numeric strings (\"abc\"), non-numeric JSON types (bool/array/object), NaN/Inf strings, fractional values (1.5), or out-of-int-range magnitudes. The error wraps the underlying cause with %w, so the nested message tells you exactly which sub-case fired.","triggerScenarios":"issue_number: \"#42\"; per_page: \"thirty\"; pull_number: 1.5 or true; page: \"NaN\"; any of the toInt failure modes reached through a required int parameter.","commonSituations":"IDs copied from UI text with decorations; quoted numbers from LLMs; fractional computed values; boolean sent where count expected.","solutions":["Read the wrapped cause after the colon — 'invalid numeric value', 'expected number, got bool', 'non-integer numeric value', etc. each has its own fix.","Send a plain JSON integer for the parameter.","If the value comes from user/LLM text, sanitize to /^-?\\d+$/ before sending.","Round computed values and confirm they are finite before the call."],"exampleFix":"// before\narguments = { owner, repo, issue_number: \"#42\" };\n// after\narguments = { owner, repo, issue_number: 42 };","handlingStrategy":"try-catch","validationCode":"function intParam(args, name) {\n  const v = args[name];\n  if (v === undefined) throw new Error(`missing required parameter: ${name}`);\n  const n = typeof v === \"string\" ? Number(v.trim()) : v;\n  if (typeof n !== \"number\" || !Number.isInteger(n) || !Number.isFinite(n)) {\n    throw new Error(`parameter ${name} is not a valid number: ${JSON.stringify(v)}`);\n  }\n  if (n === 0) throw new Error(`missing required parameter: ${name} (zero)`);\n  return n;\n}","typeGuard":"function isValidRequiredInt(v: unknown): v is number {\n  const n = typeof v === \"string\" ? Number(v) : v;\n  return typeof n === \"number\" && Number.isFinite(n) && Number.isInteger(n) && n !== 0;\n}","tryCatchPattern":"The error chains the cause with %w — match /parameter (\\w+) is not a valid number: (.+)/ and branch on the suffix: 'invalid numeric value' → sanitize the string; 'expected number, got T' → fix the JSON type; 'non-integer' → round; 'non-finite' → fix computation; 'out of int range' → clamp. Retry once after the targeted fix.","preventionTips":["Normalize every numeric argument through one shared client helper before dispatch.","Sanitize human/LLM-sourced ids with /^-?\\d+$/ early.","Log the raw offending value (included in the message) to shorten diagnosis loops."],"tags":["validation","numeric","argument-parsing","wrapped-error","mcp-tool"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}