{"record":{"id":"5dbf5fb550744c28","repo":"tomnomnom/gron","slug":"cannot-merge-array-with-non-array","errorCode":null,"errorMessage":"cannot merge array with non-array","messagePattern":"cannot merge array with non-array","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"ungron.go","lineNumber":456,"sourceCode":"\t\treturn nil, fmt.Errorf(\"unexpected token `%s`\", t.text)\n\t}\n}\n\n// recursiveMerge merges maps and slices, or returns b for scalars\nfunc recursiveMerge(a, b interface{}) (interface{}, error) {\n\tswitch a.(type) {\n\n\tcase map[string]interface{}:\n\t\tbMap, ok := b.(map[string]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"cannot merge object with non-object\")\n\t\t}\n\t\treturn recursiveMapMerge(a.(map[string]interface{}), bMap)\n\n\tcase []interface{}:\n\t\tbSlice, ok := b.([]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"cannot merge array with non-array\")\n\t\t}\n\t\treturn recursiveSliceMerge(a.([]interface{}), bSlice)\n\n\tcase string, int, float64, bool, nil, json.Number:\n\t\t// Can't merge them, second one wins\n\t\treturn b, nil\n\n\tdefault:\n\t\treturn nil, fmt.Errorf(\"unexpected data type for merge: `%s`\", reflect.TypeOf(a))\n\t}\n}\n\n// recursiveMapMerge recursively merges map[string]interface{} values\nfunc recursiveMapMerge(a, b map[string]interface{}) (map[string]interface{}, error) {\n\t// Merge keys from b into a\n\tfor k, v := range b {\n\t\t_, exists := a[k]\n\t\tif !exists {","sourceCodeStart":438,"sourceCodeEnd":474,"githubUrl":"https://github.com/tomnomnom/gron/blob/88a6234ea2d0c487090988182ad9a7cdf6def924/ungron.go#L438-L474","documentation":"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.","triggerScenarios":"Thrown at ungron.go:456 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"88a6234ea2d0c487090988182ad9a7cdf6def924","analyzedAt":"2026-09-06T11:35:31.658Z","contentChangedAt":"2026-09-06T11:35:31.658Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}