{"id":"163a004f5b0af077","repo":"go-redis/redis","slug":"redis-unexpected-response-v","errorCode":null,"errorMessage":"redis: unexpected response %#v","messagePattern":"redis: unexpected response %#v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":6368,"sourceCode":"\t\treturn err\n\t}\n\tresultMap := map[string]interface{}{}\n\n\tswitch midResponse := data.(type) {\n\tcase map[interface{}]interface{}: // resp3 will return map\n\t\tfor k, v := range midResponse {\n\t\t\tstringKey, ok := k.(string)\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"redis: invalid map key %#v\", k)\n\t\t\t}\n\t\t\tresultMap[stringKey] = v\n\t\t}\n\tcase []interface{}: // resp2 will return array of arrays\n\t\tn := len(midResponse)\n\t\tfor i := 0; i < n; i++ {\n\t\t\tfinalArr, ok := midResponse[i].([]interface{}) // final array that we need to transform to map\n\t\t\tif !ok {\n\t\t\t\treturn fmt.Errorf(\"redis: unexpected response %#v\", data)\n\t\t\t}\n\t\t\tm := len(finalArr)\n\t\t\tif m%2 != 0 { // since this should be map, keys should be even number\n\t\t\t\treturn fmt.Errorf(\"redis: unexpected response %#v\", data)\n\t\t\t}\n\n\t\t\tfor j := 0; j < m; j += 2 {\n\t\t\t\tstringKey, ok := finalArr[j].(string) // the first one\n\t\t\t\tif !ok {\n\t\t\t\t\treturn fmt.Errorf(\"redis: invalid map key %#v\", finalArr[i])\n\t\t\t\t}\n\t\t\t\tresultMap[stringKey] = finalArr[j+1] // second one is value\n\t\t\t}\n\t\t}\n\tdefault:\n\t\treturn fmt.Errorf(\"redis: unexpected response %#v\", data)\n\t}\n","sourceCodeStart":6350,"sourceCodeEnd":6386,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L6350-L6386","documentation":"Thrown by MapMapStringInterfaceCmd.readReply (command.go:6368) on the RESP2 branch. The reply is expected to be an array of [key, value, ...] pairs; if any top-level element is not itself an array (e.g. a string or integer), the parser cannot turn it into a map and aborts.","triggerScenarios":"client.FTConfigGet(ctx, option) over RESP2 when the reply is not the expected array-of-arrays shape — e.g. a module/server that returns a flat array, an error-like bulk string mixed in, or a proxy that reshapes the reply.","commonSituations":"Module version mismatch (RediSearch FT.CONFIG reply shape changed); querying an option that does not exist returns an unexpected layout; RESP-rewriting proxy.","solutions":["Inspect the raw reply (`redis-cli FT.CONFIG GET <option>`) and compare against what go-redis expects (array of [k, v, ...] pairs).","Upgrade/downgrade the RediSearch module to a version whose reply shape matches, or upgrade go-redis.","Only query known-valid CONFIG options.","Remove any intermediary that reshapes the reply."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"v, err := client.FTConfigGet(ctx, option).Result()\nif err != nil {\n    // confirm option exists / module loaded; degrade to empty map\n    v = map[string]interface{}{}\n}","preventionTips":["Only query known FT.CONFIG options.","Confirm module is loaded and reply shape with redis-cli."],"tags":["redisearch","ft-config","resp2","resp-parsing"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}