{"record":{"id":"59200db6c35f919c","repo":"tsenart/vegeta","slug":"rate-0-requires-setting-max-workers","errorCode":null,"errorMessage":"-rate=0 requires setting -max-workers","messagePattern":"-rate=0 requires setting -max-workers","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"attack.go","lineNumber":119,"sourceCode":"\tredirects      int\n\tmaxBody        int64\n\theaders        headers\n\tproxyHeaders   headers\n\tladdr          localAddr\n\tkeepalive      bool\n\tresolvers      csl\n\tunixSocket     string\n\tpromAddr       string\n\tdnsTTL         time.Duration\n\tsessionTickets bool\n\tconnectTo      map[string][]string\n}\n\n// attack validates the attack arguments, sets up the\n// required resources, launches the attack and writes the results\nfunc attack(opts *attackOpts) (err error) {\n\tif opts.maxWorkers == vegeta.DefaultMaxWorkers && opts.rate.Freq == 0 {\n\t\treturn fmt.Errorf(\"-rate=0 requires setting -max-workers\")\n\t}\n\n\tif len(opts.resolvers) > 0 {\n\t\tres, err := resolver.NewResolver(opts.resolvers)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tnet.DefaultResolver = res\n\t}\n\n\tnet.DefaultResolver.PreferGo = true\n\n\tfiles := map[string]io.Reader{}\n\tfor _, filename := range []string{opts.targetsf, opts.bodyf} {\n\t\tif filename == \"\" {\n\t\t\tcontinue\n\t\t}\n\t\tf, err := file(filename, false)","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/attack.go#L101-L137","documentation":"Vegeta's attack command rejects a configuration where the request rate is left at its default (Freq==0, i.e. `-rate=0` meaning 'as fast as possible') while the worker pool is also left at the default max-workers. In that mode throughput is unbounded and driven entirely by workers, so vegeta requires an explicit worker count to avoid an ambiguous/accidentally unlimited attack. This is a deliberate argument-validation guard in attack().","triggerScenarios":"Running `vegeta attack -rate=0 ...` (or omitting -rate so it defaults to 0) without also passing a `-max-workers` value other than the default (DefaultMaxWorkers).","commonSituations":"Users copying old vegeta examples where `-rate=0` meant unlimited rate; CI scripts that pass -rate=0 for maximum throughput but forget -max-workers; users upgrading vegeta and hitting the newly enforced rule.","solutions":["Pass an explicit worker count, e.g. add `-max-workers=10` (or the concurrency you want) alongside `-rate=0`.","If you did not intend unlimited rate, set a real rate such as `-rate=100/s` and leave -max-workers at its default.","If -rate is read from a config/variable, ensure it is never the zero value unless max-workers is also set."],"exampleFix":"// before\nvegeta attack -rate=0 -duration=10s -targets=targets.txt\n// after\nvegeta attack -rate=0 -max-workers=50 -duration=10s -targets=targets.txt","handlingStrategy":"validation","validationCode":"if rate == 0 && maxWorkers == vegeta.DefaultMaxWorkers {\n    return fmt.Errorf(\"-rate=0 requires setting -max-workers\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass -max-workers explicitly when using -rate=0.","Wrap vegeta invocations in a script that asserts rate/max-workers combination before exec.","Keep rate and worker settings together in one config block to avoid partial overrides."],"tags":["cli","configuration","validation","load-testing"],"backgroundTag":"invalid-flag-combination","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-09-01T08:17:40.651Z"}