{"id":"6c8ff7efdcfb980c","repo":"go-redis/redis","slug":"redis-resp3-map-key-must-be-a-scalar-type-got-t","errorCode":null,"errorMessage":"redis: RESP3 map key must be a scalar type, got %T","messagePattern":"redis: RESP3 map key must be a scalar type, got %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/proto/reader.go","lineNumber":469,"sourceCode":"func (r *Reader) readMap(line []byte) (map[interface{}]interface{}, error) {\n\tn, err := replyLen(line)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tm := make(map[interface{}]interface{}, n)\n\tfor i := 0; i < n; i++ {\n\t\tk, err := r.ReadReply()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\t// Reject unhashable keys (arrays/maps) before they are used as a map\n\t\t// key, which would otherwise panic. This check must run before the\n\t\t// value is read so it also guards the Nil and RedisError paths below,\n\t\t// which write the key into the map and continue.\n\t\tswitch k.(type) {\n\t\tcase []interface{}, map[interface{}]interface{}:\n\t\t\treturn nil, fmt.Errorf(\"redis: RESP3 map key must be a scalar type, got %T\", k)\n\t\t}\n\n\t\tv, err := r.ReadReply()\n\t\tif err != nil {\n\t\t\tif err == Nil {\n\t\t\t\tm[k] = nil\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\tif err, ok := err.(RedisError); ok {\n\t\t\t\tm[k] = err\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\treturn nil, err\n\t\t}\n\n\t\tm[k] = v\n\t}\n\treturn m, nil","sourceCodeStart":451,"sourceCodeEnd":487,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/internal/proto/reader.go#L451-L487","documentation":"Error \"redis: RESP3 map key must be a scalar type, got %T\" thrown in go-redis/redis.","triggerScenarios":"Thrown at internal/proto/reader.go:469 when the library encounters an invalid state.","commonSituations":"For commands with unusual replies, read into a raw/generic type instead of a typed map.","solutions":["Ensure map keys in RESP3 replies are scalar (string/int/float/bool); nested aggregates as keys are unsupported","Handle the raw reply manually if the server emits non-scalar keys"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}