go-redis/redis · error
redis: unexpected client info data (%s)
Error message
redis: unexpected client info data (%s)
What it means
Thrown by parseClientInfo (command.go:7948) which splits the CLIENT INFO / CLIENT LIST line into space-separated `key=value` tokens. If any token does not contain exactly one '=' (e.g. a value with an embedded space, or a stray token), parsing fails. The CLIENT line is verbatim 'txt' from the server.
Source
Thrown at command.go:7948
if err != nil {
return err
}
// sds o = catClientInfoString(sdsempty(), c);
// o = sdscatlen(o,"\n",1);
// addReplyVerbatim(c,o,sdslen(o),"txt");
// sdsfree(o);
cmd.val, err = parseClientInfo(strings.TrimSpace(txt))
return err
}
// fmt.Sscanf() cannot handle null values
func parseClientInfo(txt string) (info *ClientInfo, err error) {
info = &ClientInfo{}
for _, s := range strings.Split(txt, " ") {
kv := strings.Split(s, "=")
if len(kv) != 2 {
return nil, fmt.Errorf("redis: unexpected client info data (%s)", s)
}
key, val := kv[0], kv[1]
switch key {
case "id":
info.ID, err = strconv.ParseInt(val, 10, 64)
case "addr":
info.Addr = val
case "laddr":
info.LAddr = val
case "fd":
info.FD, err = strconv.ParseInt(val, 10, 64)
case "name":
info.Name = val
case "age":
var age int
if age, err = strconv.Atoi(val); err == nil {
info.Age = time.Duration(age) * time.SecondView on GitHub (pinned to 36d97525cd)
Solutions
- Avoid spaces in CLIENT SETNAME / ClientName values (use hyphens or underscores).
- Inspect the raw line (`redis-cli CLIENT INFO` / `CLIENT LIST`) for tokens without '='.
- Upgrade go-redis and Redis; newer servers escape spaces in client names.
- If parsing a single CLIENT LIST entry, ensure you pass one client line, not the whole multi-line output.
Example fix
// before: client name with a space triggers the error
client := redis.NewClient(&redis.Options{Addr: ":6379", ClientName: "my worker"})
info, err := client.ClientInfo(ctx).Result()
// after: use a space-free name
client := redis.NewClient(&redis.Options{Addr: ":6379", ClientName: "my-worker"}) Defensive patterns
Strategy: validation
Validate before calling
// Keep client names free of spaces and equals signs.
name := strings.NewReplacer(" ", "-", "=", "_").Replace(desiredName)
client := redis.NewClient(&redis.Options{Addr: ":6379", ClientName: name}) Try / catch
info, err := client.ClientInfo(ctx).Result()
if err != nil {
// CLIENT INFO is metadata; degrade to nil rather than fail the request
info = nil
} Prevention
- Never put spaces or '=' in CLIENT SETNAME / ClientName values.
- Parse one CLIENT LIST entry at a time, not the whole multi-line output.
- Treat ClientInfo parsing as best-effort.
When it happens
Trigger: Any call returning a ClientInfoCmd — client.ClientInfo(ctx), or client.ClientList(...) with a filter, or any helper that parses a CLIENT line — when a space-split token is not of the form key=value. Causes: a value containing an unescaped space (e.g. a client name with a space, or a non-standard Redis/fork adding tokens), or a corrupted/truncated line.
Common situations: Setting a client name containing spaces (redis.Options.ClientName or CLIENT SETNAME) which makes the 'name=' token split incorrectly; a fork that emits extra unkeyed tokens; transport truncation splitting the line.
Related errors
- invalid client type
- redis: unexpected client info flags(%s)
- redis: client is closed
- MaxWorkers must be greater than or equal to 0
- handoff queue size must be greater than 0
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/b8ac36237246a461.json.
Report an issue: GitHub.