{"id":"2ebacdfb512a8d83","repo":"go-redis/redis","slug":"redis-client-tracking-optin-and-optout-are-mutual","errorCode":null,"errorMessage":"redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive","messagePattern":"redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"commands.go","lineNumber":628,"sourceCode":"\t\t}\n\t\targs = appendClientTrackingOptions(args, opt)\n\t}\n\tcmd := NewStatusCmd(ctx, args...)\n\t_ = c(ctx, cmd)\n\treturn cmd\n}\n\n// ClientTrackingOff disables tracking on the serving connection. See\n// ClientTracking for the pooled-client and built-in-CSC caveats.\nfunc (c cmdable) ClientTrackingOff(ctx context.Context) *StatusCmd {\n\tcmd := NewStatusCmd(ctx, \"client\", \"tracking\", \"off\")\n\t_ = c(ctx, cmd)\n\treturn cmd\n}\n\nfunc validateClientTrackingOptions(opt *ClientTrackingOptions) error {\n\tif opt.OptIn && opt.OptOut {\n\t\treturn errors.New(\"redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive\")\n\t}\n\tif opt.Bcast && (opt.OptIn || opt.OptOut) {\n\t\treturn errors.New(\"redis: CLIENT TRACKING BCAST cannot be combined with OPTIN or OPTOUT\")\n\t}\n\tif len(opt.Prefixes) > 0 && !opt.Bcast {\n\t\treturn errors.New(\"redis: CLIENT TRACKING PREFIX requires BCAST\")\n\t}\n\treturn nil\n}\n\nfunc appendClientTrackingOptions(args []interface{}, opt *ClientTrackingOptions) []interface{} {\n\tif opt.Redirect != 0 {\n\t\targs = append(args, \"redirect\", opt.Redirect)\n\t}\n\tif opt.Bcast {\n\t\targs = append(args, \"bcast\")\n\t}\n\tfor _, p := range opt.Prefixes {","sourceCodeStart":610,"sourceCodeEnd":646,"githubUrl":"https://github.com/go-redis/redis/blob/36d97525cd8076aed67cddf54778e9ea84550929/commands.go#L610-L646","documentation":"Error \"redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive\" thrown in go-redis/redis.","triggerScenarios":"Thrown at commands.go:628 when the library encounters an invalid state.","commonSituations":"Represent tracking mode as an enum instead of two booleans to make exclusivity structural.","solutions":["Choose either OptIn or OptOut in ClientTrackingOptions, not both","Build the options from a single mode flag so the two cannot be set together"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"36d97525cd8076aed67cddf54778e9ea84550929","analyzedAt":"2026-08-06T01:08:27.376Z","schemaVersion":2}