go-redis/redis · error
redis: function list unexpected key %s
Error message
redis: function list unexpected key %s
What it means
Thrown by FunctionListCmd.readReply (command.go:6766) while parsing each library map from FUNCTION LIST. The parser only knows the keys library_name/engine/functions/library_code; any other key at the library level aborts parsing to avoid misaligning the map.
Source
Thrown at command.go:6766
library := Library{}
for f := 0; f < nn; f++ {
key, err := rd.ReadString()
if err != nil {
return err
}
switch key {
case "library_name":
library.Name, err = rd.ReadString()
case "engine":
library.Engine, err = rd.ReadString()
case "functions":
library.Functions, err = cmd.readFunctions(rd)
case "library_code":
library.Code, err = rd.ReadString()
default:
return fmt.Errorf("redis: function list unexpected key %s", key)
}
if err != nil {
return err
}
}
libraries[i] = library
}
cmd.val = libraries
return nil
}
func (cmd *FunctionListCmd) readFunctions(rd *proto.Reader) ([]Function, error) {
n, err := rd.ReadArrayLen()
if err != nil {
return nil, err
}View on GitHub (pinned to 36d97525cd)
Solutions
- Upgrade go-redis to a release that recognizes the new key.
- Pin Redis to a version whose FUNCTION LIST output your go-redis understands.
- Confirm the offending key with redis-cli (`FUNCTION LIST`).
- Avoid FunctionList if you only need a subset (use FunctionList with WITHCODE false and tolerate the failure by upgrading).
Defensive patterns
Strategy: validation
Validate before calling
// If you depend on FunctionList, gate by server version vs your go-redis. // redis-cli FUNCTION LIST -> confirm only known library-level keys are present.
Try / catch
libs, err := client.FunctionList(ctx, redis.FunctionListQuery{}).Result()
if err != nil {
// forward-compat drift; upgrade go-redis, or degrade to no-op
libs = nil
} Prevention
- Keep go-redis version aligned with Redis server version.
- Treat FunctionList as best-effort metadata.
When it happens
Trigger: client.FunctionList(ctx, q) against a Redis that added a new top-level library field the linked go-redis does not recognize (forward-compat drift), or a non-conformant fork.
Common situations: Running an older go-redis against a newer Redis that extended FUNCTION LIST's library map (e.g. added a field like 'description' or 'library_sha'); Redis fork with a different shape.
Related errors
- redis: function stats unexpected key %s
- redis: function stats unexpected running_script key %s
- redis: function stats unexpected %s engine map length
- redis: got %d elements in COMMAND reply, wanted 6/7/10
- redis: unexpected key %q in CLUSTER LINKS reply
AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06).
Data as JSON: /data/errors/5ac5be103b7cde4a.json.
Report an issue: GitHub.