{"record":{"id":"aeaa798604ebea7a","repo":"tsenart/vegeta","slug":"rate-frequency-and-time-unit-must-be-bigger-than-z","errorCode":null,"errorMessage":"rate frequency and time unit must be bigger than zero","messagePattern":"rate frequency and time unit must be bigger than zero","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"attack.go","lineNumber":75,"sourceCode":"\tfs.Var(&opts.headers, \"header\", \"Request header\")\n\tfs.Var(&opts.proxyHeaders, \"proxy-header\", \"Proxy CONNECT header\")\n\tfs.Var(&opts.laddr, \"laddr\", \"Local IP address\")\n\tfs.BoolVar(&opts.keepalive, \"keepalive\", true, \"Use persistent connections\")\n\tfs.StringVar(&opts.unixSocket, \"unix-socket\", \"\", \"Connect over a unix socket. This overrides the host address in target URLs\")\n\tfs.StringVar(&opts.promAddr, \"prometheus-addr\", \"\", \"Prometheus exporter listen address [empty = disabled]. Example: 0.0.0.0:8880\")\n\tfs.Var(&dnsTTLFlag{&opts.dnsTTL}, \"dns-ttl\", \"Cache DNS lookups for the given duration [-1 = disabled, 0 = forever]\")\n\tfs.BoolVar(&opts.sessionTickets, \"session-tickets\", false, \"Enable TLS session resumption using session tickets\")\n\tfs.Var(&connectToFlag{&opts.connectTo}, \"connect-to\", \"A mapping of (ip|host):port to use instead of a target URL's (ip|host):port. Can be repeated multiple times.\\nIdentical src:port with different dst:port will round-robin over the different dst:port pairs.\\nExample: google.com:80:localhost:6060\")\n\tsystemSpecificFlags(fs, opts)\n\n\treturn command{fs, func(args []string) error {\n\t\tfs.Parse(args)\n\t\treturn attack(opts)\n\t}}\n}\n\nvar (\n\terrZeroRate = errors.New(\"rate frequency and time unit must be bigger than zero\")\n\terrBadCert  = errors.New(\"bad certificate\")\n)\n\n// attackOpts aggregates the attack function command options\ntype attackOpts struct {\n\tname           string\n\ttargetsf       string\n\tformat         string\n\toutputf        string\n\tbodyf          string\n\tcertf          string\n\tkeyf           string\n\trootCerts      csl\n\thttp2          bool\n\th2c            bool\n\tinsecure       bool\n\tlazy           bool\n\tchunked        bool","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/tsenart/vegeta/blob/cf5811269046c672a604b1eb352204d30f16ae4a/attack.go#L57-L93","documentation":"errZeroRate is returned by vegeta's attack setup when the configured rate's frequency or per-time-unit value is zero or negative. A rate attacker cannot schedule requests without a positive request frequency and time unit, so vegeta rejects the configuration up front instead of running a no-op attack.","triggerScenarios":"Calling vegeta's attack path (CLI `vegeta attack -rate 0/s` or the library attack/attackOpts flow in attack.go) where rate.Frequency <= 0 or rate.Per <= 0 after flag parsing.","commonSituations":"Typo in the -rate flag (e.g. `-rate 0`), computing the rate programmatically from a divisor that yields 0, or zero-value rate structs passed to the library API without initialization.","solutions":["Set a positive rate, e.g. `-rate 100/s` or Rate{Frequency: 100, Per: time.Second}.","Validate the rate value before invoking attack: if opts.rate.Frequency <= 0 || opts.rate.Per <= 0, error out with a clear CLI usage message.","Check where the rate is computed (config files, flags) for zero-producing arithmetic."],"exampleFix":"// before\nvegeta attack -rate 0/s -duration 5s -targets targets.txt\n// after\nvegeta attack -rate 50/s -duration 5s -targets targets.txt","handlingStrategy":"validation","validationCode":"if rate.Frequency <= 0 || rate.Per <= 0 {\n    return fmt.Errorf(\"invalid rate %d/%s: frequency and period must be > 0\", rate.Frequency, rate.Per)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass explicit -rate like 50/s; never 0 or bare numbers","Add a CLI flag default (e.g. -rate 50/s) so zero values are impossible","Unit-test attack opts construction with boundary rates"],"tags":["configuration","validation","rate-limiting"],"backgroundTag":"invalid-configuration-value","analyzedSha":"cf5811269046c672a604b1eb352204d30f16ae4a","analyzedAt":"2026-08-31T11:04:20.464Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}