redis/go-redis · error
invalid suggestion score value
Error message
invalid suggestion score value
What it means
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.
Source
Thrown at search_commands.go:2564
suggestionsData, ok := termInfo[2].([]interface{})
if !ok {
return nil, fmt.Errorf("invalid suggestions format")
}
suggestions := make([]SpellCheckSuggestion, 0, len(suggestionsData))
for _, suggestionData := range suggestionsData {
suggestionInfo, ok := suggestionData.([]interface{})
if !ok || len(suggestionInfo) != 2 {
return nil, fmt.Errorf("invalid suggestion format")
}
scoreStr, ok := suggestionInfo[0].(string)
if !ok {
return nil, fmt.Errorf("invalid suggestion score format")
}
score, err := strconv.ParseFloat(scoreStr, 64)
if err != nil {
return nil, fmt.Errorf("invalid suggestion score value")
}
suggestion, ok := suggestionInfo[1].(string)
if !ok {
return nil, fmt.Errorf("invalid suggestion format")
}
suggestions = append(suggestions, SpellCheckSuggestion{
Score: score,
Suggestion: suggestion,
})
}
results = append(results, SpellCheckResult{
Term: term,
Suggestions: suggestions,
})
}View on GitHub (pinned to c5cad058c7)
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
Example fix
// before: ignoring the error
cmd := rdb.FTSpellCheck(ctx, "idx", query)
res, _ := cmd.Result()
// after: surface and inspect the raw reply
res, err := rdb.FTSpellCheck(ctx, "idx", query).Result()
if err != nil {
log.Printf("spellcheck parse failed: %v; raw=%v", err, raw)
return fallbackTerms
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-validate server compatibility
if err := rdb.FTInfo(ctx, index).Err(); err != nil {
return fmt.Errorf("RediSearch unavailable: %w", err)
} Type guard
func isValidScoreString(s string) bool {
_, err := strconv.ParseFloat(s, 64)
return err == nil
} Try / catch
res, err := rdb.FTSpellCheck(ctx, "idx", term).Result()
if err != nil {
if strings.Contains(err.Error(), "invalid suggestion") {
log.Printf("spellcheck reply malformed, using no suggestions: %v", err)
return nil, nil
}
return nil, err
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- unexpected search result format
- invalid total results format
- invalid document ID format
- invalid score format
- invalid document fields format
AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01).
Data as JSON: /api/errors/18670a77680fe9f9.
Report an issue: GitHub.