{"id":"4e9df6ae173a4793","repo":"go-redis/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":7000,"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":6982,"sourceCodeEnd":7018,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/command.go#L6982-L7018","documentation":"Thrown by FunctionStatsCmd.readRunningScript (command.go:7000). The running_script map is expected to have exactly the keys name/duration_ms/command; any other key aborts. The map length is also fixed at 3 (ReadFixedMapLen(3)).","triggerScenarios":"client.FunctionStats(ctx) when a function is running and the server's running_script map contains an unexpected key (or more than 3 entries) — typically a newer Redis adding running-script metadata that go-redis does not know.","commonSituations":"Forward-compat drift on newer Redis; Redis Enterprise/fork extending the running-script shape.","solutions":["Upgrade go-redis to a release supporting the new running-script field.","Pin Redis to a compatible version.","Retry when no function is running (running_script becomes nil and this branch is skipped)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Confirm running_script keys via redis-cli while a function is executing.","typeGuard":null,"tryCatchPattern":"stats, err := client.FunctionStats(ctx).Result()\nif err != nil {\n    // upgrade go-redis; retry when no function is running to skip this branch\n    stats = redis.FunctionStats{}\n}","preventionTips":["Upgrade go-redis alongside Redis.","Avoid calling FunctionStats during known running functions if your go-redis is older."],"tags":["functions","function-stats","resp-parsing","version-mismatch"],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}