{"record":{"id":"c18bb6a6ca5c47b5","repo":"github/github-mcp-server","slug":"invalid-numeric-value-s","errorCode":null,"errorMessage":"invalid numeric value: %s","messagePattern":"invalid numeric value: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/params.go","lineNumber":75,"sourceCode":"// isAcceptedError checks if the error is an accepted error.\nfunc isAcceptedError(err error) bool {\n\tvar acceptedError *github.AcceptedError\n\treturn errors.As(err, &acceptedError)\n}\n\n// toInt converts a value to int, handling both float64 and string representations.\n// Some MCP clients send numeric values as strings. It rejects NaN, ±Inf,\n// fractional values, and values outside the int range.\nfunc toInt(val any) (int, error) {\n\tvar f float64\n\tswitch v := val.(type) {\n\tcase float64:\n\t\tf = v\n\tcase string:\n\t\tvar err error\n\t\tf, err = strconv.ParseFloat(v, 64)\n\t\tif err != nil {\n\t\t\treturn 0, fmt.Errorf(\"invalid numeric value: %s\", v)\n\t\t}\n\tdefault:\n\t\treturn 0, fmt.Errorf(\"expected number, got %T\", val)\n\t}\n\tif math.IsNaN(f) || math.IsInf(f, 0) {\n\t\treturn 0, fmt.Errorf(\"non-finite numeric value\")\n\t}\n\tif f != math.Trunc(f) {\n\t\treturn 0, fmt.Errorf(\"non-integer numeric value: %v\", f)\n\t}\n\tif f > math.MaxInt || f < math.MinInt {\n\t\treturn 0, fmt.Errorf(\"numeric value out of int range: %v\", f)\n\t}\n\treturn int(f), nil\n}\n\n// toInt64 converts a value to int64, handling both float64 and string representations.\n// Some MCP clients send numeric values as strings. It rejects NaN, ±Inf,","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/params.go#L57-L93","documentation":"Thrown by toInt in pkg/github/params.go when a numeric argument is sent as a string but strconv.ParseFloat cannot parse it. toInt is the coercion layer for RequiredInt/optional int params: it accepts float64 (JSON numbers) and numeric strings (\"30\", \"1e3\"), and any string ParseFloat rejects produces this error.","triggerScenarios":"per_page: \"abc\", page: \"1-5\", per_page: \"30px\", or a string with whitespace/commas like \"1,000\" passed to a tool using int parameters.","commonSituations":"LLM-generated numeric strings with units or punctuation; form input forwarded verbatim; locale-formatted numbers (\"1.000,00\"); truncated or corrupted string payloads.","solutions":["Send the value as a real JSON number instead of a string.","If it must be a string, make it a clean decimal literal parseable by Go's ParseFloat (\"30\", \"-5\", \"1e3\").","Strip units, separators, and whitespace on the client before sending.","Note the error is wrapped by RequiredInt as \"parameter %s is not a valid number\" — read the nested cause for the offending string."],"exampleFix":"// before\narguments: { owner, repo, page: \"1,000\" }\n// after\narguments: { owner, repo, page: 1000 }","handlingStrategy":"validation","validationCode":"function toIntArg(v) {\n  if (typeof v === \"number\") return v;\n  if (typeof v === \"string\" && /^[-+]?(\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?$/.test(v.trim())) {\n    return Number(v);\n  }\n  throw new Error(`not a parseable number: ${JSON.stringify(v)}`);\n}","typeGuard":"function isNumericString(v: unknown): v is string {\n  return typeof v === \"string\" && v.trim() !== \"\" && !isNaN(Number(v));\n}","tryCatchPattern":"Catch the wrapped 'not a valid number: ... invalid numeric value: <s>' text, sanitize or replace the offending string, retry once; surface the bad value to the user if it came from input.","preventionTips":["Strip thousand separators, units, and whitespace from numeric strings at the source.","Prefer JSON numbers for numeric fields in all generated code.","Validate user-supplied counts with a digits-only regex before building arguments."],"tags":["validation","numeric","string-parsing","argument-parsing","mcp-tool"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}