go-redis/redis · error
invalid suggestion format
Error message
invalid suggestion format
What it means
Returned by parseFTSpellCheck (RESP2 path) when a suggestion element is not a 2-element array. Each suggestion is [score, suggestion]; any other arity or type is rejected at search_commands.go:2553.
Source
Thrown at search_commands.go:2555
if !ok || len(termInfo) != 3 {
return nil, fmt.Errorf("invalid term format")
}
term, ok := termInfo[1].(string)
if !ok {
return nil, fmt.Errorf("invalid term format")
}
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,View on GitHub (pinned to 36d97525cd)
Solutions
- Upgrade Redis Stack/RediSearch to a version with the standard [score, suggestion] format.
- Inspect the raw reply with cmd.RawResult() to confirm the offending tuple.
- Ensure you are connected to a real RediSearch-enabled Redis.
Example fix
null
Defensive patterns
Strategy: try-catch
Type guard
func isSuggestionTuple(v interface{}) bool {
t, ok := v.([]interface{})
return ok && len(t) == 2
} Try / catch
if err != nil && strings.Contains(err.Error(), "invalid suggestion format") {
// RawResult to find which tuple is malformed
} Prevention
- Upgrade RediSearch to emit the standard [score, suggestion] tuple.
- Verify the endpoint is RediSearch, not a generic Redis.
- Log raw replies on parse failure.
When it happens
Trigger: A RESP2 FT.SPELLCHECK reply whose inner suggestion tuples are not [score, suggestion] pairs of length 2.
Common situations: Server/module version that emits a different suggestion tuple shape, or a non-RediSearch backend.
Related errors
- invalid term format
- invalid suggestions format
- invalid suggestion score format
- invalid suggestion score value
- invalid results format: expected map, got %T
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/0834818b9a8baece.json.
Report an issue: GitHub.