{"record":{"id":"5a5d09cac5c61df4","repo":"vitessio/vitess","slug":"enable-and-disable-are-mutually-exclusive","errorCode":null,"errorMessage":"--enable and --disable are mutually exclusive","messagePattern":"--enable and --disable are mutually exclusive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/vtctl/grpcvtctldserver/server.go","lineNumber":2100,"sourceCode":"\t\t}\n\n\t\tsrvKeyspaces[cell] = srvKeyspace\n\t}\n\n\treturn &vtctldatapb.GetSrvKeyspacesResponse{\n\t\tSrvKeyspaces: srvKeyspaces,\n\t}, nil\n}\n\n// UpdateThrottlerConfig updates throttler config for all cells\nfunc (s *VtctldServer) UpdateThrottlerConfig(ctx context.Context, req *vtctldatapb.UpdateThrottlerConfigRequest) (resp *vtctldatapb.UpdateThrottlerConfigResponse, err error) {\n\tspan, ctx := trace.NewSpan(ctx, \"VtctldServer.UpdateThrottlerConfig\")\n\tdefer span.Finish()\n\n\tdefer panicHandler(&err)\n\n\tif req.Enable && req.Disable {\n\t\treturn nil, errors.New(\"--enable and --disable are mutually exclusive\")\n\t}\n\n\tif req.MetricName != \"\" && !base.KnownMetricNames.Contains(base.MetricName(req.MetricName)) {\n\t\treturn nil, fmt.Errorf(\"unknown metric name: %s\", req.MetricName)\n\t}\n\n\tif len(req.AppCheckedMetrics) > 0 {\n\t\tspecifiedMetrics := map[base.MetricName]bool{}\n\t\tfor _, metricName := range req.AppCheckedMetrics {\n\t\t\t_, knownMetric, err := base.DisaggregateMetricName(metricName)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"invalid metric name: %s\", metricName)\n\t\t\t}\n\t\t\tif _, ok := specifiedMetrics[knownMetric]; ok {\n\t\t\t\treturn nil, fmt.Errorf(\"duplicate metric name: %s\", knownMetric)\n\t\t\t}\n\t\t\tspecifiedMetrics[knownMetric] = true\n\t\t}","sourceCodeStart":2082,"sourceCodeEnd":2118,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/vtctl/grpcvtctldserver/server.go#L2082-L2118","documentation":"UpdateThrottlerConfig treats Enable and Disable as contradictory directives: one call cannot simultaneously turn the throttle check on and off. When both booleans are set the request is rejected outright rather than picking a winner, forcing the caller to state one unambiguous intent.","triggerScenarios":"Calling vtctld UpdateThrottlerConfig (CLI vtctldclient ThrottlerUpdateConfig / throttler status changes) with both --enable and --disable flags set, or building a request where req.Enable && req.Disable are both true.","commonSituations":"Shell scripts interpolating flags from variables where both default to true; templated automation merging enable/disable intents; copy-pasted CLI invocations keeping a stale flag from a previous line.","solutions":["Pass only one of --enable / --disable on the vtctldclient throttler command","Audit the script/automation that builds the flag list and ensure mutually exclusive flags are never both emitted","If the intent is to toggle, issue two sequential UpdateThrottlerConfig calls (disable then enable) or just the final desired state"],"exampleFix":"// before\nvtctldclient ThrottlerUpdateConfig --enable --disable --threshold 100 commerce/0\n// after\nvtctldclient ThrottlerUpdateConfig --enable --threshold 100 commerce/0","handlingStrategy":"validation","validationCode":"if enable && disable {\n    return fmt.Errorf(\"cannot pass both --enable and --disable\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Build throttler config commands from a single desired-state boolean, not independent flags","In shell scripts, emit flags from one variable: [ \"$want_enable\" = true ] && args+=(--enable)","Add a preflight assertion in CI automation that mutually exclusive flags never co-occur"],"tags":["vtctld","throttler","cli","mutually-exclusive-flags"],"backgroundTag":"mutually-exclusive-flags","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}