{"record":{"id":"18670a77680fe9f9","repo":"redis/go-redis","slug":"invalid-suggestion-score-value","errorCode":null,"errorMessage":"invalid suggestion score value","messagePattern":"invalid suggestion score value","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"search_commands.go","lineNumber":2564,"sourceCode":"\t\tsuggestionsData, ok := termInfo[2].([]interface{})\n\t\tif !ok {\n\t\t\treturn nil, fmt.Errorf(\"invalid suggestions format\")\n\t\t}\n\n\t\tsuggestions := make([]SpellCheckSuggestion, 0, len(suggestionsData))\n\t\tfor _, suggestionData := range suggestionsData {\n\t\t\tsuggestionInfo, ok := suggestionData.([]interface{})\n\t\t\tif !ok || len(suggestionInfo) != 2 {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid suggestion format\")\n\t\t\t}\n\n\t\t\tscoreStr, ok := suggestionInfo[0].(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid suggestion score format\")\n\t\t\t}\n\t\t\tscore, err := strconv.ParseFloat(scoreStr, 64)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid suggestion score value\")\n\t\t\t}\n\n\t\t\tsuggestion, ok := suggestionInfo[1].(string)\n\t\t\tif !ok {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid suggestion format\")\n\t\t\t}\n\n\t\t\tsuggestions = append(suggestions, SpellCheckSuggestion{\n\t\t\t\tScore:      score,\n\t\t\t\tSuggestion: suggestion,\n\t\t\t})\n\t\t}\n\n\t\tresults = append(results, SpellCheckResult{\n\t\t\tTerm:        term,\n\t\t\tSuggestions: suggestions,\n\t\t})\n\t}","sourceCodeStart":2546,"sourceCodeEnd":2582,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/search_commands.go#L2546-L2582","documentation":"FT.SPELLCHECK response parsing failed because the score string returned by the server could not be parsed as a float64. The RediSearch module sends each suggestion as a [score, suggestion] pair where the score is a string like \"0.5\"; go-redis uses strconv.ParseFloat on it. If the string is not a valid number, the whole FTSpellCheck command returns this error instead of a typed result.","triggerScenarios":"Calling FTSynDump/FTSpellCheck (Cmdable.FTSpellCheck) when the server returns a suggestion whose score string is not numeric — e.g. a proxy or fault-injecting RESP middleware rewrites the score, a non-RediSearch server answers, or a custom/patched module emits a malformed score.","commonSituations":"Running behind a RESP proxy (e.g. maintenance-notation fault-injection proxies, Twemproxy-like shims) that mangles replies; pointing the client at a server that is not Redis Stack / RediSearch so the reply layout is different; version mismatches where the module changes the score encoding.","solutions":["Verify you are connecting to Redis Stack with the RediSearch module (FT.INFO works) and a compatible version","Remove or fix any RESP proxy/middleware that rewrites FT.SPELLCHECK replies","Log cmd.RawResult()/raw reply to inspect the actual score string the server sent","Upgrade go-redis and the RediSearch module to matched, supported versions"],"exampleFix":"// before: ignoring the error\ncmd := rdb.FTSpellCheck(ctx, \"idx\", query)\nres, _ := cmd.Result()\n\n// after: surface and inspect the raw reply\nres, err := rdb.FTSpellCheck(ctx, \"idx\", query).Result()\nif err != nil {\n\tlog.Printf(\"spellcheck parse failed: %v; raw=%v\", err, raw)\n\treturn fallbackTerms\n}","handlingStrategy":"try-catch","validationCode":"// Pre-validate server compatibility\nif err := rdb.FTInfo(ctx, index).Err(); err != nil {\n\treturn fmt.Errorf(\"RediSearch unavailable: %w\", err)\n}","typeGuard":"func isValidScoreString(s string) bool {\n\t_, err := strconv.ParseFloat(s, 64)\n\treturn err == nil\n}","tryCatchPattern":"res, err := rdb.FTSpellCheck(ctx, \"idx\", term).Result()\nif err != nil {\n\tif strings.Contains(err.Error(), \"invalid suggestion\") {\n\t\tlog.Printf(\"spellcheck reply malformed, using no suggestions: %v\", err)\n\t\treturn nil, nil\n\t}\n\treturn nil, err\n}","preventionTips":["Run against genuine Redis Stack with FT.INFO-checked module availability","Avoid RESP-rewriting proxies on spellcheck paths","Log RawResult() when parsing errors occur to capture wire format","Pin matched go-redis/RediSearch versions"],"tags":["go-redis","rediseearch","resp-parsing","spellcheck"],"backgroundTag":"resp-reply-parse-failed","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}