tomnomnom/gron · error
cannot merge array with non-array
Error message
cannot merge array with non-array
What it means
recursiveMerge was asked to merge a []interface{} with a value whose dynamic type is not a slice, which cannot be combined. The input assigns both an array and a non-array (object or scalar) to the same indexed key path.
Source
Thrown at ungron.go:456
return nil, fmt.Errorf("unexpected token `%s`", t.text)
}
}
// recursiveMerge merges maps and slices, or returns b for scalars
func recursiveMerge(a, b interface{}) (interface{}, error) {
switch a.(type) {
case map[string]interface{}:
bMap, ok := b.(map[string]interface{})
if !ok {
return nil, fmt.Errorf("cannot merge object with non-object")
}
return recursiveMapMerge(a.(map[string]interface{}), bMap)
case []interface{}:
bSlice, ok := b.([]interface{})
if !ok {
return nil, fmt.Errorf("cannot merge array with non-array")
}
return recursiveSliceMerge(a.([]interface{}), bSlice)
case string, int, float64, bool, nil, json.Number:
// Can't merge them, second one wins
return b, nil
default:
return nil, fmt.Errorf("unexpected data type for merge: `%s`", reflect.TypeOf(a))
}
}
// recursiveMapMerge recursively merges map[string]interface{} values
func recursiveMapMerge(a, b map[string]interface{}) (map[string]interface{}, error) {
// Merge keys from b into a
for k, v := range b {
_, exists := a[k]
if !exists {View on GitHub (pinned to 88a6234ea2)
Solutions
- Ensure the conflicting key path is an array in every statement that mentions it
- Change one of the conflicting assignments so the types agree
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at ungron.go:456 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/5dbf5fb550744c28.
Report an issue: GitHub.