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

  1. Upgrade Redis Stack/RediSearch to a version with the standard [score, suggestion] format.
  2. Inspect the raw reply with cmd.RawResult() to confirm the offending tuple.
  3. 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

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


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/0834818b9a8baece.json. Report an issue: GitHub.