go-redis/redis · error

invalid suggestion score value

Error message

invalid suggestion score value

What it means

Returned by parseFTSpellCheck (RESP2 path) when the suggestion score string cannot be parsed by strconv.ParseFloat. The score slot is a string but not a valid floating-point number (e.g. empty, "inf", "nan"-like, or garbage). Guard at search_commands.go:2562-2564.

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 36d97525cd)

Solutions

  1. Capture the raw score string via cmd.RawResult() to see exactly what was returned.
  2. Upgrade RediSearch; treat a non-numeric score as a server/module defect.
  3. Check for network-level corruption (TLS issues, buffering proxy).

Example fix

null
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil && strings.Contains(err.Error(), "invalid suggestion score value") {
    // RawResult to capture the offending score string; treat as server defect
}

Prevention

When it happens

Trigger: A RESP2 FT.SPELLCHECK reply whose score bulk string is non-numeric. The assertion to string passes but ParseFloat fails.

Common situations: Corrupted or truncated reply over the wire, a server bug emitting a placeholder string, or a proxy injecting bad data.

Related errors


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