github/github-mcp-server · error
parameter %s: failed to convert element %d (%s) to int64: %w
Error message
parameter %s: failed to convert element %d (%s) to int64: %w
What it means
Returned by OptionalBigIntArrayParam when an element is a valid string but convertStringToBigInt (ParseInt base 10, 64-bit) rejects it. Identical failure surface to error 267 but hit through the []any branch where elements were individually asserted to string first; the parameter name, index, and element value are included.
Source
Thrown at pkg/github/params.go:335
if _, ok := args[p]; !ok {
return []int64{}, nil
}
switch v := args[p].(type) {
case nil:
return []int64{}, nil
case []string:
return convertStringSliceToBigIntSlice(v)
case []any:
int64Slice := make([]int64, len(v))
for i, v := range v {
s, ok := v.(string)
if !ok {
return []int64{}, fmt.Errorf("parameter %s is not of type string, is %T", p, v)
}
val, err := convertStringToBigInt(s, 0)
if err != nil {
return []int64{}, fmt.Errorf("parameter %s: failed to convert element %d (%s) to int64: %w", p, i, s, err)
}
int64Slice[i] = val
}
return int64Slice, nil
default:
return []int64{}, fmt.Errorf("parameter %s could not be coerced to []int64, is %T", p, args[p])
}
}
// WithPagination adds REST API pagination parameters to a tool.
// https://docs.github.com/en/rest/using-the-rest-api/using-pagination-in-the-rest-api
func WithPagination(schema *jsonschema.Schema) *jsonschema.Schema {
schema.Properties["page"] = &jsonschema.Schema{
Type: "number",
Description: "Page number for pagination (min 1)",
Minimum: jsonschema.Ptr(1.0),
}
View on GitHub (pinned to 0ea1f775a7)
Solutions
- Validate each element with strconv.ParseInt client-side and drop/report invalid entries before the call
- Confirm you are collecting numeric database IDs, not base64 GraphQL node IDs (those belong in string ID params)
- Normalize external input (trim, de-format) at ingestion time
Example fix
// before
{"column_ids":["3743572","MDM6VGVzdA=="]}
// after
{"column_ids":["3743572"]} Defensive patterns
Strategy: validation
Validate before calling
func validateBigIntArray(args map[string]any, p string) error {
v, ok := args[p]
if !ok {
return nil
}
arr, ok := v.([]any)
if !ok {
if ss, ok2 := v.([]string); ok2 {
arr = toAnySlice(ss)
} else {
return fmt.Errorf("%s must be an array", p)
}
}
for i, e := range arr {
s, ok := e.(string)
if !ok {
return fmt.Errorf("%s[%d] must be a string, got %T", p, i, e)
}
if _, err := strconv.ParseInt(s, 10, 64); err != nil {
return fmt.Errorf("%s[%d]=%q invalid int64: %w", p, i, s, err)
}
}
return nil
} Type guard
func isValidBigIntArrayParam(args map[string]any, p string) bool {
return validateBigIntArray(args, p) == nil
} Try / catch
ids, err := github.OptionalBigIntArrayParam(args, "repository_ids")
if err != nil {
if strings.Contains(err.Error(), "failed to convert element") {
// element-level problem: clean the list and retry once
ids, err = github.OptionalBigIntArrayParam(cleanedArgs(args), "repository_ids")
}
if err != nil {
return err
}
} Prevention
- Validate ID arrays with strconv.ParseInt before dispatch
- Do not mix GraphQL node IDs into numeric-ID arrays
- Fail fast on the first bad element in ingestion pipelines rather than at call time
When it happens
Trigger: ["ok","12.5"] style arrays where one element is non-numeric or empty; an ID string exceeding int64 range; elements with whitespace, commas, or exponent notation.
Common situations: Mixed-quality ID lists assembled from multiple API pages; stale cached IDs whose format changed (e.g. GraphQL global node IDs confused with numeric database IDs); user-entered IDs from a form with stray characters.
Related errors
- failed to convert element %d (%s) to int64: %w
- parameter %s is not of type string, is %T
- parameter %s could not be coerced to []string, is %T
- failed to convert string %s to int64: %w
- parameter %s could not be coerced to []int64, is %T
AI-assisted analysis of github/github-mcp-server@0ea1f775a7 (2026-08-15).
Data as JSON: /api/errors/4239e4801f129c5b.
Report an issue: GitHub.