{"record":{"id":"045a606d2f95a582","repo":"redis/go-redis","slug":"redis-function-stats-unexpected-running-script-ke","errorCode":null,"errorMessage":"redis: function stats unexpected running_script key %s","messagePattern":"redis: function stats unexpected running_script key (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"command.go","lineNumber":7006,"sourceCode":"\t\treturn RunningScript{}, false, err\n\t}\n\n\tvar runningScript RunningScript\n\tfor i := 0; i < 3; i++ {\n\t\tkey, err := rd.ReadString()\n\t\tif err != nil {\n\t\t\treturn RunningScript{}, false, err\n\t\t}\n\n\t\tswitch key {\n\t\tcase \"name\":\n\t\t\trunningScript.Name, err = rd.ReadString()\n\t\tcase \"duration_ms\":\n\t\t\trunningScript.Duration, err = cmd.readDuration(rd)\n\t\tcase \"command\":\n\t\t\trunningScript.Command, err = cmd.readCommand(rd)\n\t\tdefault:\n\t\t\treturn RunningScript{}, false, fmt.Errorf(\"redis: function stats unexpected running_script key %s\", key)\n\t\t}\n\n\t\tif err != nil {\n\t\t\treturn RunningScript{}, false, err\n\t\t}\n\t}\n\n\treturn runningScript, true, nil\n}\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++ {","sourceCodeStart":6988,"sourceCodeEnd":7024,"githubUrl":"https://github.com/redis/go-redis/blob/c5cad058c72f58370553b48566302303cf8a2e89/command.go#L6988-L7024","documentation":"This error is thrown while parsing the reply to FUNCTION STATS when the running_script map contains a key the client does not recognize. go-redis expects a fixed set of keys (e.g. name, duration_ms, command) inside the running_script object and fails fast on anything else to avoid silently dropping data. It usually indicates a Redis server version emitting a newer FUNCTION STATS format than the client supports.","triggerScenarios":"Calling FunctionStats() (or FCALL-based stats flows) against a Redis server whose FUNCTION STATS reply includes a new running_script field not in the parser's known-key switch at command.go:~7006.","commonSituations":"Upgrading the Redis server (e.g. Redis 8.x function engine changes) while using an older go-redis version; running against a proxy or fork that adds fields to the FUNCTION STATS reply.","solutions":["Upgrade go-redis to the latest version so the FUNCTION STATS parser knows the new keys.","Check the Redis server version and whether it is stock Redis (proxies/forks can alter the reply).","If on the latest client and the key is genuinely new, file an issue at redis/go-redis with the raw reply.","As a workaround, avoid calling FunctionStats() on the mismatched server version."],"exampleFix":"// before: older client fails on new key\nstats, err := rdb.FunctionStats(ctx)\n// redis: function stats unexpected running_script key new_field\n\n// after: upgrade module\n// go get github.com/redis/go-redis/v9@latest\nstats, err := rdb.FunctionStats(ctx)","handlingStrategy":"try-catch","validationCode":"// check server/client compatibility before parsing\ninfo, err := rdb.Info(ctx, \"server\").Result()\n// verify redis_version is one your go-redis release supports","typeGuard":null,"tryCatchPattern":"stats, err := rdb.FunctionStats(ctx)\nif err != nil {\n    if strings.Contains(err.Error(), \"unexpected running_script key\") {\n        // fall back to raw FUNCTION STATS via redis.Do and parse manually\n    }\n    return err\n}","preventionTips":["Keep go-redis and the Redis server versions in sync","Pin server versions in test environments","Treat unknown reply fields as a signal to upgrade the client","Watch go-redis release notes when upgrading Redis"],"tags":["redis","function-stats","reply-parsing","version-mismatch"],"backgroundTag":"unsupported-server-reply-format","analyzedSha":"c5cad058c72f58370553b48566302303cf8a2e89","analyzedAt":"2026-09-01T06:50:53.388Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}