{"record":{"id":"46f5cca92f6b4e8d","repo":"vitessio/vitess","slug":"maxrate-must-be-0-v","errorCode":null,"errorMessage":"maxRate must be >= 0: %v","messagePattern":"maxRate must be >= 0: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"go/vt/throttler/throttler.go","lineNumber":166,"sourceCode":"\nfunc NewThrottlerFromConfig(name, unit string, threadCount int, maxRateModuleMaxRate int64, maxReplicationLagModuleConfig MaxReplicationLagModuleConfig, nowFunc func() time.Time) (Throttler, error) {\n\treturn newThrottlerFromConfig(GlobalManager, name, unit, threadCount, maxRateModuleMaxRate, maxReplicationLagModuleConfig, nowFunc)\n}\n\nfunc newThrottler(manager *managerImpl, name, unit string, threadCount int, maxRate, maxReplicationLag int64, nowFunc func() time.Time) (Throttler, error) {\n\tconfig := NewMaxReplicationLagModuleConfig(maxReplicationLag)\n\tconfig.MaxReplicationLagSec = maxReplicationLag\n\n\treturn newThrottlerFromConfig(manager, name, unit, threadCount, maxRate, config, nowFunc)\n}\n\nfunc newThrottlerFromConfig(manager *managerImpl, name, unit string, threadCount int, maxRateModuleMaxRate int64, maxReplicationLagModuleConfig MaxReplicationLagModuleConfig, nowFunc func() time.Time) (Throttler, error) {\n\terr := maxReplicationLagModuleConfig.Verify()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"invalid max replication lag config: %w\", err)\n\t}\n\tif maxRateModuleMaxRate < 0 {\n\t\treturn nil, fmt.Errorf(\"maxRate must be >= 0: %v\", maxRateModuleMaxRate)\n\t}\n\n\t// Enable the configured modules.\n\tmaxRateModule := NewMaxRateModule(maxRateModuleMaxRate)\n\tactualRateHistory := newAggregatedIntervalHistory(1024, 1*time.Second, threadCount)\n\tmaxReplicationLagModule, err := NewMaxReplicationLagModule(maxReplicationLagModuleConfig, actualRateHistory, nowFunc)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\n\tmodules := make([]Module, 0, 2)\n\tmodules = append(modules, maxRateModule)\n\tmodules = append(modules, maxReplicationLagModule)\n\n\t// Start each module (which might start own Go routines).\n\trateUpdateChan := make(chan struct{}, 10)\n\tfor _, m := range modules {\n\t\tm.Start(rateUpdateChan)","sourceCodeStart":148,"sourceCodeEnd":184,"githubUrl":"https://github.com/vitessio/vitess/blob/01a25a7d176f94613b8d59d799f438380a8760e4/go/vt/throttler/throttler.go#L148-L184","documentation":"Returned by throttler rate config validation when maxRate is negative; a negative maximum rate is meaningless and the value must be zero or positive.","triggerScenarios":"NewThrottlerFromConfig or newThrottler called with maxRate < 0, e.g. parsing a negative value from a flag or config field like --max-rate.","commonSituations":"Sign errors when computing rates programmatically; misparsed flags; template/config typo producing -1 for 'unlimited' instead of 0.","solutions":["Pass maxRate >= 0; use 0 or the appropriate disabled sentinel for 'no explicit limit'.","Clamp or validate the rate before calling NewThrottlerFromConfig (e.g. if maxRate < 0 { maxRate = 0 }).","Check the flag/config source for a stray negative sign."],"exampleFix":"// before\nmaxRate := -1 // meant unlimited\n// after\nmaxRate := 0","handlingStrategy":"validation","validationCode":"if maxRate < 0 {\n    return errors.New(\"maxRate must be >= 0\")\n}","typeGuard":null,"tryCatchPattern":"t, err := throttler.NewThrottlerFromConfig(mgr, name, unit, threads, maxRate, cfg, nowFunc)\nif err != nil {\n    return err\n}","preventionTips":["Clamp parsed max-rate flags to >= 0.","Use 0 as the 'unset' value, never negative numbers.","Validate numeric flags with bounds checking in PreRunE-style setup."],"tags":["go","throttler","config-validation"],"backgroundTag":"invalid-argument-value","analyzedSha":"01a25a7d176f94613b8d59d799f438380a8760e4","analyzedAt":"2026-09-01T17:28:30.605Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}