go-redis/redis · error

redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusi

Error message

redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive

What it means

Error "redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive" thrown in go-redis/redis.

Source

Thrown at commands.go:628

		}
		args = appendClientTrackingOptions(args, opt)
	}
	cmd := NewStatusCmd(ctx, args...)
	_ = c(ctx, cmd)
	return cmd
}

// ClientTrackingOff disables tracking on the serving connection. See
// ClientTracking for the pooled-client and built-in-CSC caveats.
func (c cmdable) ClientTrackingOff(ctx context.Context) *StatusCmd {
	cmd := NewStatusCmd(ctx, "client", "tracking", "off")
	_ = c(ctx, cmd)
	return cmd
}

func validateClientTrackingOptions(opt *ClientTrackingOptions) error {
	if opt.OptIn && opt.OptOut {
		return errors.New("redis: CLIENT TRACKING OPTIN and OPTOUT are mutually exclusive")
	}
	if opt.Bcast && (opt.OptIn || opt.OptOut) {
		return errors.New("redis: CLIENT TRACKING BCAST cannot be combined with OPTIN or OPTOUT")
	}
	if len(opt.Prefixes) > 0 && !opt.Bcast {
		return errors.New("redis: CLIENT TRACKING PREFIX requires BCAST")
	}
	return nil
}

func appendClientTrackingOptions(args []interface{}, opt *ClientTrackingOptions) []interface{} {
	if opt.Redirect != 0 {
		args = append(args, "redirect", opt.Redirect)
	}
	if opt.Bcast {
		args = append(args, "bcast")
	}
	for _, p := range opt.Prefixes {

View on GitHub (pinned to 36d97525cd)

Solutions

  1. Choose either OptIn or OptOut in ClientTrackingOptions, not both
  2. Build the options from a single mode flag so the two cannot be set together

When it happens

Trigger: Thrown at commands.go:628 when the library encounters an invalid state.

Common situations: Represent tracking mode as an enum instead of two booleans to make exclusivity structural.


AI-assisted analysis of go-redis/redis@36d97525cd (2026-08-06). Data as JSON: /data/errors/2ebacdfb512a8d83.json. Report an issue: GitHub.