{"record":{"id":"a9119ff2873c1d52","repo":"github/github-mcp-server","slug":"failed-to-convert-string-s-to-int64-w","errorCode":null,"errorMessage":"failed to convert string %s to int64: %w","messagePattern":"failed to convert string (.+?) to int64: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/params.go","lineNumber":306,"sourceCode":"\t}\n}\n\nfunc convertStringSliceToBigIntSlice(s []string) ([]int64, error) {\n\tint64Slice := make([]int64, len(s))\n\tfor i, str := range s {\n\t\tval, err := convertStringToBigInt(str, 0)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"failed to convert element %d (%s) to int64: %w\", i, str, err)\n\t\t}\n\t\tint64Slice[i] = val\n\t}\n\treturn int64Slice, nil\n}\n\nfunc convertStringToBigInt(s string, def int64) (int64, error) {\n\tv, err := strconv.ParseInt(s, 10, 64)\n\tif err != nil {\n\t\treturn def, fmt.Errorf(\"failed to convert string %s to int64: %w\", s, err)\n\t}\n\treturn v, nil\n}\n\n// OptionalBigIntArrayParam 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, if not, it returns an empty slice\n// 2. If it is present, iterates the elements, checks each is a string, and converts them to int64 values\nfunc OptionalBigIntArrayParam(args map[string]any, p string) ([]int64, error) {\n\t// Check if the parameter is present in the request\n\tif _, ok := args[p]; !ok {\n\t\treturn []int64{}, nil\n\t}\n\n\tswitch v := args[p].(type) {\n\tcase nil:\n\t\treturn []int64{}, nil\n\tcase []string:","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/params.go#L288-L324","documentation":"Returned by convertStringToBigInt when strconv.ParseInt fails on a base-10 64-bit parse of a string. It is the leaf conversion error wrapped by the slice converters (267, 270). The %w-embedded error is strconv's *NumError, whose Reason field is ErrSyntax for malformed strings or ErrRange for overflow.","triggerScenarios":"ParseInt on \"\", \"abc\", \"12.0\", \"+ 1\", or hex/exponent forms → ErrSyntax; parsing \"99999999999999999999\" (> int64 max 9223372036854775807) → ErrRange; strings containing U+FFFD or non-ASCII digits.","commonSituations":"IDs scraped from HTML/UI text carrying formatting; locale digit groupings; JavaScript clients serializing BigInt targets as strings with an 'n' suffix (\"123n\") after JSON.stringify quirks.","solutions":["Validate strings with strconv.ParseInt(s, 10, 64) client-side before sending","Strip formatting characters (commas, spaces, 'n' suffixes, quotes) at the boundary where external data enters","For >64-bit values confirm the target parameter truly takes int64; if it takes a GitHub GraphQL node ID, send the base64 string in the *_id string parameter instead"],"exampleFix":"// before\n{\"repository_id\":\"123n\"}\n// after\n{\"repository_id\":\"123\"}","handlingStrategy":"validation","validationCode":"func parseBigInt(s string) (int64, error) {\n    s = strings.TrimSpace(s)\n    s = strings.ReplaceAll(s, \",\", \"\")\n    n, err := strconv.ParseInt(s, 10, 64)\n    if err != nil {\n        return 0, fmt.Errorf(\"%q is not a base-10 int64: %w\", s, err)\n    }\n    return n, nil\n}","typeGuard":"func isParsableInt64(s string) bool {\n    _, err := strconv.ParseInt(strings.TrimSpace(s), 10, 64)\n    return err == nil\n}","tryCatchPattern":"n, err := convertStringToBigInt(idStr, 0)\nif err != nil {\n    var ne *strconv.NumError\n    if errors.As(err, &ne) && ne.Err == strconv.ErrRange {\n        // out of int64 range: wrong kind of ID — route to the string-ID parameter\n    }\n    // ErrSyntax: clean the string and retry once\n}","preventionTips":["Standardize on trimmed, unformatted base-10 strings for numeric IDs","Distinguish ErrSyntax vs ErrRange when handling strconv errors — they need different fixes","Watch for 'n' suffixes from BigInt serialization when integrating JS clients"],"tags":["go","strconv","type-conversion","parameter-validation"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}