go-redis/redis · error

invalid field value format

Error message

invalid field value format

What it means

Companion to the previous check (search_commands.go:2676-2678): each field's value (odd-index element) must also be a string in the FT.SEARCH reply. A non-string value trips this error.

Source

Thrown at search_commands.go:2678

			fields, ok := data[i].([]interface{})
			if !ok {
				if data[i] == proto.Nil || data[i] == nil {
					doc.Error = proto.Nil
					doc.Fields = map[string]string{}
					fields = []interface{}{}
				} else {
					return FTSearchResult{}, fmt.Errorf("invalid document fields format")
				}
			}

			for j := 0; j < len(fields); j += 2 {
				key, ok := fields[j].(string)
				if !ok {
					return FTSearchResult{}, fmt.Errorf("invalid field key format")
				}
				value, ok := fields[j+1].(string)
				if !ok {
					return FTSearchResult{}, fmt.Errorf("invalid field value format")
				}
				doc.Fields[key] = value
			}
			i++
		}

		results = append(results, doc)
	}
	return FTSearchResult{
		Total: int(total),
		Docs:  results,
	}, nil
}

type FTSearchCmd struct {
	baseCmd
	val     FTSearchResult
	options *FTSearchOptions

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Inspect RawResult() to find the failing field index.
  2. Confirm the index schema and AS clause produce string-encoded values.
  3. Compare with redis-cli output.
  4. Upgrade server and client.
Defensive patterns

Strategy: try-catch

Try / catch

if err != nil && strings.Contains(err.Error(), "invalid field value format") {
    raw, _ := cmd.RawResult()
    log.Printf("field value not string; raw=%#v", raw)
}

Prevention

When it happens

Trigger: Server returned a non-string field value (e.g. an integer where go-redis expects a string-encoded value), or a misaligned parser read a key as a value.

Common situations: Schema/encoding mismatch (e.g. SORTABLE numeric returned as int), proxy-induced shape changes, or version drift.

Related errors


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