redis/go-redis · error

redis: function list unexpected key %s

Error message

redis: function list unexpected key %s

What it means

Thrown by the FUNCTION LIST reply parser when it encounters a map key other than the documented `library_name`, `engine`, `functions`, or `library_code` (command.go, FunctionList readReply). Redis added a new field to the FUNCTION LIST reply that this client version doesn't know, or a compatible server emits extra keys.

Source

Thrown at command.go:6772

		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 c5cad058c7)

Solutions

  1. Upgrade go-redis to the latest v9 release, which recognizes newer FUNCTION LIST fields.
  2. Check the error's key name and compare with `redis-cli --raw FUNCTION LIST` output on your server to identify the new field.
  3. As a stopgap, downgrade the server or avoid FUNCTION LIST against that server version.
  4. If the key comes from a proxy/Enterprise fork, file an issue with go-redis including the raw reply.

Example fix

// before: server upgraded to a Redis version with new FUNCTION LIST fields, old client
go get github.com/redis/go-redis/v9@latest

// after: client parser knows the new keys
require github.com/redis/go-redis/v9 v9.x.y // latest
Defensive patterns

Strategy: try-catch

Validate before calling

// check Redis version supports the FUNCTION LIST format this client parses
ver := redisVersion(rdb) // from INFO server
if ver == nil || ver.LessThan(semver.MustParse("7.0.0")) {
    return nil, errors.New("function list unsupported")
}

Try / catch

libs, err := rdb.FunctionList(ctx, "*", true)
if err != nil {
    if strings.Contains(err.Error(), "function list unexpected key") {
        // server adds unknown fields: upgrade go-redis or treat as unsupported
        return nil, fmt.Errorf("FUNCTION LIST format unsupported by client: %w", err)
    }
    return err
}

Prevention

When it happens

Trigger: Calling `client.FunctionList(ctx, pattern, withCode)` against a Redis server (often 7.x/8.x or Redis Enterprise) whose FUNCTION LIST reply contains a key this go-redis version doesn't recognize — e.g. a newly added metadata field.

Common situations: Upgrading the Redis server ahead of the client library; Redis Enterprise forks adding extra reply fields; running a nightly/preview Redis build with new function metadata.

Related errors


AI-assisted analysis of redis/go-redis@c5cad058c7 (2026-09-01). Data as JSON: /api/errors/76bdb9912c235fd9. Report an issue: GitHub.