tomnomnom/gron · error
invalid integer key `%s`
Error message
invalid integer key `%s`
What it means
During un-groning, a token classified as a numeric array key (typNumericKey) cannot be parsed by strconv.Atoi, so the token text is not a valid integer index. This indicates an internal tokenization inconsistency, since only digit tokens should be tagged typNumericKey.
Source
Thrown at ungron.go:424
case t.typ == typQuotedKey:
val, err := ungronTokens(ts[1:])
if err != nil {
return nil, err
}
key := ""
err = json.Unmarshal([]byte(t.text), &key)
if err != nil {
return nil, fmt.Errorf("invalid quoted key `%s`", t.text)
}
out := make(map[string]interface{})
out[key] = val
return out, nil
case t.typ == typNumericKey:
key, err := strconv.Atoi(t.text)
if err != nil {
return nil, fmt.Errorf("invalid integer key `%s`", t.text)
}
val, err := ungronTokens(ts[1:])
if err != nil {
return nil, err
}
// There needs to be at least key + 1 space in the array
out := make([]interface{}, key+1)
out[key] = val
return out, nil
default:
return nil, fmt.Errorf("unexpected token `%s`", t.text)
}
}
// recursiveMerge merges maps and slices, or returns b for scalarsView on GitHub (pinned to 88a6234ea2)
Solutions
- Inspect the statement that produced the token; the input likely contains a malformed bracket expression with a non-integer index
- Re-run with the offending input corrected so array keys are plain integers
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at ungron.go:424 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of tomnomnom/gron@88a6234ea2 (2026-09-06).
Data as JSON: /api/errors/ea32e3bbf81c4ecd.
Report an issue: GitHub.