{"record":{"id":"15361389c2f956c2","repo":"github/github-mcp-server","slug":"failed-to-convert-element-d-s-to-int64-w","errorCode":null,"errorMessage":"failed to convert element %d (%s) to int64: %w","messagePattern":"failed to convert element (.+?) \\((.+?)\\) to int64: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/github/params.go","lineNumber":296,"sourceCode":"\t\tfor i, v := range v {\n\t\t\ts, ok := v.(string)\n\t\t\tif !ok {\n\t\t\t\treturn []string{}, fmt.Errorf(\"parameter %s is not of type string, is %T\", p, v)\n\t\t\t}\n\t\t\tstrSlice[i] = s\n\t\t}\n\t\treturn strSlice, nil\n\tdefault:\n\t\treturn []string{}, fmt.Errorf(\"parameter %s could not be coerced to []string, is %T\", p, args[p])\n\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","sourceCodeStart":278,"sourceCodeEnd":314,"githubUrl":"https://github.com/github/github-mcp-server/blob/0ea1f775a7c73eff1bd2e25904d01136756bbfe2/pkg/github/params.go#L278-L314","documentation":"Returned by convertStringSliceToBigIntSlice when one element of an already-[]string array fails convertStringToBigInt (strconv.ParseInt base 10, 64-bit). The message includes the failing index and original string so the offending element is identifiable, and the wrapped ParseInt error distinguishes syntax from range failures.","triggerScenarios":"An element like \"12.5\", \"1e5\", \" 42\", \"\", \"0x1F\", or a value beyond int64 range; an empty-string element in an otherwise numeric list; elements with thousands separators such as \"1,000,000\".","commonSituations":"Forwarding display-formatted or localized numbers (IDs with commas) into ID-array parameters like repository_ids or issue IDs; LLM-generated lists mixing label names with numeric IDs in one array; copy/paste introducing invisible whitespace.","solutions":["Pass IDs as plain base-10 digit strings without separators, signs, spaces, or exponent notation","Sanitize externally sourced strings (trim, strip commas) before building the array","For out-of-range values, verify the source actually returned an int64-sized ID — if not, the wrong field is being collected"],"exampleFix":"// before\n{\"repository_ids\":[\"123\", \"1,402\", \"\"]}\n// after\n{\"repository_ids\":[\"123\",\"1402\"]}","handlingStrategy":"validation","validationCode":"func validateIDStrings(ids []string) error {\n    for i, s := range ids {\n        if _, err := strconv.ParseInt(s, 10, 64); err != nil {\n            return fmt.Errorf(\"element %d (%q) is not a valid int64: %w\", i, s, err)\n        }\n    }\n    return nil\n}","typeGuard":"func allElementsInt64(s []string) bool {\n    for _, v := range s {\n        if _, err := strconv.ParseInt(v, 10, 64); err != nil {\n            return false\n        }\n    }\n    return true\n}","tryCatchPattern":"ids, err := github.OptionalStringArrayParam(args, \"repository_ids\")\nif err != nil {\n    return err\n}\nif err := validateIDStrings(ids); err != nil {\n    // drop or repair bad elements before converting downstream\n    return err\n}","preventionTips":["De-format numbers (strip commas/units/whitespace) when ingesting from text sources","Validate ID lists once at ingestion and store the validated form","Prefer numeric database IDs over GraphQL node IDs for int64 array parameters"],"tags":["go","mcp","type-conversion","arrays","strconv"],"backgroundTag":null,"analyzedSha":"0ea1f775a7c73eff1bd2e25904d01136756bbfe2","analyzedAt":"2026-08-15T18:10:19.804Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}