go-redis/redis · error

redis: can't parse reply=%T reading string

Error message

redis: can't parse reply=%T reading string

What it means

Returned by readVectorAttribStringOrNil (command.go:8742) when reading a vector attribute value from the reply that is not a string or nil. The helper calls rd.ReadReply() and expects a bulk string (or nil for missing attributes); receiving any other RESP type (integer, array, error) triggers this. Used internally by all VSIM WITHATTRIBS command reply parsers.

Source

Thrown at command.go:8742

		}
	}
	return &VectorScoreSliceSliceCmd{
		baseCmd: cmd.cloneBaseCmd(),
		val:     val,
	}
}

func readVectorAttribStringOrNil(rd *proto.Reader) (*string, error) {
	v, err := rd.ReadReply()
	if err != nil {
		if err == proto.Nil {
			return nil, nil
		}
		return nil, err
	}
	s, ok := v.(string)
	if !ok {
		return nil, fmt.Errorf("redis: can't parse reply=%T reading string", v)
	}
	return &s, nil
}

type VectorAttribSliceCmd struct {
	baseCmd

	val []VectorAttrib
}

var _ Cmder = (*VectorAttribSliceCmd)(nil)

func NewVectorAttribSliceCmd(ctx context.Context, args ...any) *VectorAttribSliceCmd {
	return &VectorAttribSliceCmd{
		baseCmd: baseCmd{
			ctx:  ctx,
			args: args,
		},

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Upgrade Redis and the VectorSet module to a version compatible with this go-redis
  2. Verify that element attributes were properly set via VSETATTR as JSON strings before querying with WITHATTRIBS
  3. Switch to RESP3 (Protocol: 3) to get structured map replies
  4. File a bug report if the server consistently returns non-string attributes for elements that have none set

Example fix

// before - querying WITHATTRIBS on elements without attributes set
res, err := rdb.VSimWithArgsWithAttribs(ctx, "mykey", vec, &redis.VSimArgs{}).Result()

// after - ensure attributes are set as JSON strings first
rdb.VSetAttr(ctx, "mykey", "elem", `{"category":"a"}`)
res, err := rdb.VSimWithArgsWithAttribs(ctx, "mykey", vec, &redis.VSimArgs{Count: 10}).Result()
Defensive patterns

Strategy: try-catch

Validate before calling

// Ensure elements have string attributes set via VSETATTR before querying WITHATTRIBS
ok, err := rdb.VSetAttr(ctx, "mykey", "elem", `{"cat":"a"}`).Result()
if err != nil {
    return err
}

Try / catch

res, err := rdb.VSimWithArgsWithAttribs(ctx, key, vec, args).Result()
if err != nil && strings.Contains(err.Error(), "can't parse reply") {
    log.Error("VSIM returned non-string attribute; check server compatibility and element attributes")
}

Prevention

When it happens

Trigger: Calling VSimWithArgsWithAttribs or VSimWithArgsWithScoresWithAttribs where the server returns a non-string value in the attribute slot of the reply.

Common situations: Server returns attributes as a non-string RESP type (e.g., integer, null-array, or nested structure); VectorSet module version incompatibility; a proxy altering the reply type; server-side bug in attribute serialization.

Related errors


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