{"id":"5ac5be103b7cde4a","repo":"go-redis/redis","slug":"redis-function-list-unexpected-key-s","errorCode":null,"errorMessage":"redis: function list unexpected key %s","messagePattern":"redis: function list unexpected key (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":6766,"sourceCode":"\n\t\tlibrary := Library{}\n\t\tfor f := 0; f < nn; f++ {\n\t\t\tkey, err := rd.ReadString()\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\n\t\t\tswitch key {\n\t\t\tcase \"library_name\":\n\t\t\t\tlibrary.Name, err = rd.ReadString()\n\t\t\tcase \"engine\":\n\t\t\t\tlibrary.Engine, err = rd.ReadString()\n\t\t\tcase \"functions\":\n\t\t\t\tlibrary.Functions, err = cmd.readFunctions(rd)\n\t\t\tcase \"library_code\":\n\t\t\t\tlibrary.Code, err = rd.ReadString()\n\t\t\tdefault:\n\t\t\t\treturn fmt.Errorf(\"redis: function list unexpected key %s\", key)\n\t\t\t}\n\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\n\t\tlibraries[i] = library\n\t}\n\tcmd.val = libraries\n\treturn nil\n}\n\nfunc (cmd *FunctionListCmd) readFunctions(rd *proto.Reader) ([]Function, error) {\n\tn, err := rd.ReadArrayLen()\n\tif err != nil {\n\t\treturn nil, err\n\t}","sourceCodeStart":6748,"sourceCodeEnd":6784,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L6748-L6784","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// If you depend on FunctionList, gate by server version vs your go-redis.\n// redis-cli FUNCTION LIST  -> confirm only known library-level keys are present.","typeGuard":null,"tryCatchPattern":"libs, err := client.FunctionList(ctx, redis.FunctionListQuery{}).Result()\nif err != nil {\n    // forward-compat drift; upgrade go-redis, or degrade to no-op\n    libs = nil\n}","preventionTips":["Keep go-redis version aligned with Redis server version.","Treat FunctionList as best-effort metadata."],"tags":["functions","function-list","resp-parsing","version-mismatch"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}