go-redis/redis · error

invalid result item format

Error message

invalid result item format

What it means

Returned in parseFTHybrid (search_commands.go:3094-3099): each entry in the results array must be either a map (RESP3 style) or an array of key/value pairs (RESP2 style). An item that is neither (scalar, nil) trips this error.

Solutions

  1. Inspect RawResult() and locate the offending result item.
  2. Upgrade the server module and go-redis.
  3. Reproduce via redis-cli.
  4. File a go-redis issue with the raw reply if persistent.
Defensive patterns

Strategy: try-catch

Try / catch

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

Prevention

When it happens

Trigger: FHybrid results array containing an item of an unexpected type — e.g. a bare string or integer where a per-result map/array was expected.

Common situations: Server returned a heterogeneous or partial result list, or a future reply variant go-redis does not handle.

Related errors


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /api/errors/4eb2a7fc3fe69889. Report an issue: GitHub.

Appendix: source

Thrown at search_commands.go:3098

			continue
		}

		// Try parsing as map[interface{}]interface{} (alternative RESP3 format)
		if rawMap, ok := item.(map[interface{}]interface{}); ok {
			itemMap := make(map[string]interface{})
			for k, v := range rawMap {
				if keyStr, ok := k.(string); ok {
					itemMap[keyStr] = v
				}
			}
			results = append(results, itemMap)
			continue
		}

		// Fall back to array format (RESP2 format - key-value pairs)
		itemData, ok := item.([]interface{})
		if !ok {
			return FTHybridResult{}, nil, fmt.Errorf("invalid result item format")
		}

		itemMap := make(map[string]interface{})
		for i := 0; i < len(itemData); i += 2 {
			if i+1 < len(itemData) {
				key, ok := itemData[i].(string)
				if !ok {
					return FTHybridResult{}, nil, fmt.Errorf("invalid item key format")
				}
				itemMap[key] = itemData[i+1]
			}
		}
		results = append(results, itemMap)
	}

	// Optional warnings; accept both "warning" (as FT.SEARCH/FT.AGGREGATE) and "warnings".
	var warnings []string
	warningsData, ok := resultMap["warning"].([]interface{})

View on GitHub (pinned to 36d97525cd)