{"id":"e100ce458f48289d","repo":"go-redis/redis","slug":"redis-function-stats-unexpected-s-engine-map-len","errorCode":null,"errorMessage":"redis: function stats unexpected %s engine map length","messagePattern":"redis: function stats unexpected (.+?) engine map length","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":7027,"sourceCode":"}\n\nfunc (cmd *FunctionStatsCmd) readEngines(rd *proto.Reader) ([]Engine, error) {\n\tn, err := rd.ReadMapLen()\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tengines := make([]Engine, 0, n)\n\tfor i := 0; i < n; i++ {\n\t\tengine := Engine{}\n\t\tengine.Language, err = rd.ReadString()\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\terr = rd.ReadFixedMapLen(2)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"redis: function stats unexpected %s engine map length\", engine.Language)\n\t\t}\n\n\t\tfor i := 0; i < 2; i++ {\n\t\t\tkey, err := rd.ReadString()\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tswitch key {\n\t\t\tcase \"libraries_count\":\n\t\t\t\tengine.LibrariesCount, err = rd.ReadInt()\n\t\t\tcase \"functions_count\":\n\t\t\t\tengine.FunctionsCount, err = rd.ReadInt()\n\t\t\tdefault:\n\t\t\t\t// Unknown field: drain its value so the reader stays aligned\n\t\t\t\t// with the rest of the reply.\n\t\t\t\terr = rd.DiscardNext()\n\t\t\t}\n\t\t\tif err != nil {","sourceCodeStart":7009,"sourceCodeEnd":7045,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L7009-L7045","documentation":"Thrown by FunctionStatsCmd.readEngines (command.go:7027) when each engine's value map is not exactly 2 entries (libraries_count and functions_count). The parser uses ReadFixedMapLen(2), so any other length aborts.","triggerScenarios":"client.FunctionStats(ctx) when an engine map under 'engines' has a length other than 2 — e.g. a newer Redis added a third engine-stat field, or a fork/proxy returned a different shape.","commonSituations":"Forward-compat drift: newer Redis adding per-engine statistics; Redis fork with a different engines shape.","solutions":["Upgrade go-redis to a release supporting the new engine-stat fields (or that drains extra fields).","Pin Redis to a compatible version.","Confirm with `FUNCTION STATS` what keys each engine map contains."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// redis-cli FUNCTION STATS  -> confirm each engine map has exactly libraries_count + functions_count.","typeGuard":null,"tryCatchPattern":"stats, err := client.FunctionStats(ctx).Result()\nif err != nil {\n    // upgrade go-redis for new engine-stat fields; degrade\n    stats = redis.FunctionStats{}\n}","preventionTips":["Pin Redis to a version your go-redis supports, or upgrade go-redis first.","Treat engine stats as best-effort."],"tags":["functions","function-stats","resp-parsing","version-mismatch"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}