go-redis/redis · error

invalid total_results format

Error message

invalid total_results format

What it means

Thrown in parseFTHybrid (search_commands.go:3064-3067): the 'total_results' field of the FTHybrid reply map must be an int64. Any other type (string, float, nil, missing) trips this error.

Source

Thrown at search_commands.go:3066

	}

	// Handle cursor result
	if withCursor {
		searchCursorID, ok1 := resultMap["SEARCH"].(int64)
		vsimCursorID, ok2 := resultMap["VSIM"].(int64)
		if !ok1 || !ok2 {
			return FTHybridResult{}, nil, fmt.Errorf("invalid cursor result format")
		}
		return FTHybridResult{}, &FTHybridCursorResult{
			SearchCursorID: int(searchCursorID),
			VsimCursorID:   int(vsimCursorID),
		}, nil
	}

	// Parse regular result
	totalResults, ok := resultMap["total_results"].(int64)
	if !ok {
		return FTHybridResult{}, nil, fmt.Errorf("invalid total_results format")
	}

	resultsData, ok := resultMap["results"].([]interface{})
	if !ok {
		return FTHybridResult{}, nil, fmt.Errorf("invalid results format")
	}

	// Parse each result item
	results := make([]map[string]interface{}, 0, len(resultsData))
	for _, item := range resultsData {
		// Try parsing as map[string]interface{} first (RESP3 format)
		if itemMap, ok := item.(map[string]interface{}); ok {
			results = append(results, itemMap)
			continue
		}

		// Try parsing as map[interface{}]interface{} (alternative RESP3 format)
		if rawMap, ok := item.(map[interface{}]interface{}); ok {

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Inspect RawResult() for the total_results value and its Go type.
  2. Upgrade go-redis and the hybrid module to matched versions.
  3. Reproduce via redis-cli to see the canonical reply.
  4. If field name changed, file a go-redis issue.
Defensive patterns

Strategy: try-catch

Try / catch

res, _, err := client.FTHybridWithArgs(ctx, idx, opts).Result()
if err != nil && strings.Contains(err.Error(), "invalid total_results format") {
    raw, _ := cmd.RawVal()
    log.Printf("fthybrid total_results not int64; raw=%#v", raw)
}

Prevention

When it happens

Trigger: FTHybrid reply whose total_results was emitted as a non-integer (e.g. a string '5'), or where the field is absent so resultMap[...] yields nil.

Common situations: Version mismatch between go-redis and the server hybrid module, or a reply from an older/newer module variant that renamed or retyped the field.

Related errors


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