{"id":"80c8372a210e871e","repo":"go-redis/redis","slug":"invalid-results-format-expected-map-got-t","errorCode":null,"errorMessage":"invalid results format: expected map, got %T","messagePattern":"invalid results format: expected map, got %T","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":2473,"sourceCode":"//\t  \"results\": map{\n//\t    \"misspelled_term\": [\n//\t      map{\"suggestion\": score},\n//\t      ...\n//\t    ],\n//\t    ...\n//\t  }\n//\t}\nfunc parseFTSpellCheckRESP3(data map[interface{}]interface{}) ([]SpellCheckResult, error) {\n\tresults := make([]SpellCheckResult, 0)\n\n\tresultsData, ok := data[\"results\"]\n\tif !ok {\n\t\treturn results, nil\n\t}\n\n\tresultsMap, ok := resultsData.(map[interface{}]interface{})\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid results format: expected map, got %T\", resultsData)\n\t}\n\n\tfor termKey, suggestionsData := range resultsMap {\n\t\tterm, ok := termKey.(string)\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tsuggestionsArray, ok := suggestionsData.([]interface{})\n\t\tif !ok {\n\t\t\tcontinue\n\t\t}\n\n\t\tsuggestions := make([]SpellCheckSuggestion, 0, len(suggestionsArray))\n\t\tfor _, suggestionData := range suggestionsArray {\n\t\t\tsuggestionMap, ok := suggestionData.(map[interface{}]interface{})\n\t\t\tif !ok {\n\t\t\t\tcontinue","sourceCodeStart":2455,"sourceCodeEnd":2491,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/search_commands.go#L2455-L2491","documentation":"Returned by parseFTSpellCheckRESP3 when the top-level \"results\" entry is not itself a map[interface{}]interface{}. RediSearch RESP3 spellcheck wraps per-term suggestion lists under a results map; a non-map value means the shape diverged. The guard is at search_commands.go:2471.","triggerScenarios":"A RESP3 FT.SPELLCHECK reply whose \"results\" value is an array, scalar, or nil rather than a map. Typically server-version or module-output drift.","commonSituations":"Mixing a newer go-redis client with an older RediSearch whose RESP3 spellcheck schema differs, or a server that returns an empty/non-map payload on certain error states.","solutions":["Use RESP2 (Protocol: 2) to get the array-based spellcheck format this client also supports.","Upgrade RediSearch/Redis Stack to match the client's expected RESP3 schema.","If the index doesn't exist or the term has no results, ensure the server still returns a well-formed results map."],"exampleFix":"// before\nclient := redis.NewClient(&redis.Options{Addr: addr, Protocol: 3})\nclient.FTSpellCheck(ctx, \"idx\", term)\n\n// after\nclient := redis.NewClient(&redis.Options{Addr: addr /* RESP2 */})\nclient.FTSpellCheck(ctx, \"idx\", term)","handlingStrategy":"try-catch","validationCode":"// Use RESP2 to get the array-based spellcheck format this client robustly supports.","typeGuard":null,"tryCatchPattern":"res, err := client.FTSpellCheck(ctx, idx, term).Result()\nif err != nil && strings.Contains(err.Error(), \"invalid results format\") {\n    // switch to RESP2 client or upgrade RediSearch, then retry\n}","preventionTips":["Match go-redis and RediSearch versions for RESP3 schema compatibility.","Falls back to RESP2 spellcheck when RESP3 shape is uncertain.","Inspect RawResult when the parser rejects the shape."],"tags":["redisearch","ft-spellcheck","resp3","parsing","schema-mismatch"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}