tsenart/vegeta · error
-rate format %q doesn't match the "freq/duration" format (i.
Error message
-rate format %q doesn't match the "freq/duration" format (i.e. 50/1s)
What it means
vegeta's Rate flag parses '-rate' as freq/duration. strings.SplitN(v,"/",2) yielding 0 parts (an empty -rate value) means the value cannot match the documented "freq/duration" format, so Set rejects it with this message.
Source
Thrown at flags.go:79
*l = strings.Split(v, ",")
return nil
}
func (l csl) String() string { return strings.Join(l, ",") }
type rateFlag struct{ *vegeta.Rate }
func (f *rateFlag) Set(v string) (err error) {
if v == "infinity" {
return nil
}
ps := strings.SplitN(v, "/", 2)
switch len(ps) {
case 1:
ps = append(ps, "1s")
case 0:
return fmt.Errorf("-rate format %q doesn't match the \"freq/duration\" format (i.e. 50/1s)", v)
}
f.Freq, err = strconv.Atoi(ps[0])
if err != nil {
return err
}
if f.Freq == 0 {
return nil
}
switch ps[1] {
case "ns", "us", "µs", "ms", "s", "m", "h":
ps[1] = "1" + ps[1]
}
f.Per, err = time.ParseDuration(ps[1])
return errView on GitHub (pinned to cf58112690)
Solutions
- Supply a value in "freq/duration" form, e.g. -rate=50/1s.
- Use the shorthand -rate=50, which defaults the duration to 1s.
- In scripts, guard against empty variables: ${RATE:-50/1s}.
- Note Atoi errors on the freq part produce a different error; this one is specifically for an empty value.
Example fix
// before vegeta attack -rate=$RATE ... # RATE unset -> empty // after vegeta attack -rate=50/1s ...
Defensive patterns
Strategy: validation
Validate before calling
func validRate(s string) bool {
if s == "" {
return false
}
parts := strings.SplitN(s, "/", 2)
if _, err := strconv.Atoi(parts[0]); err != nil {
return false
}
if len(parts) == 2 {
if _, err := time.ParseDuration(parts[1]); err != nil {
return false
}
}
return true
} Prevention
- Never pass an empty -rate value; default it in scripts (${RATE:-50/1s}).
- Use the documented 'freq/duration' form like 50/1s.
- Remember bare integers like 50 are valid (duration defaults to 1s).
- Fail fast in wrappers if the rate variable is unset.
When it happens
Trigger: Passing an empty string to the -rate flag (e.g. -rate="" or an unbound shell variable expanding to nothing), so the split produces zero parts.
Common situations: Scripted invocations where a RATE variable is unset/empty; config templating leaving the flag blank; copy-pasted examples that omit the value.
Related errors
- -max-body=%d overflows int64
- invalid -connect-to %q, expected format: %s
- bad buckets: %s
- -rate=0 requires setting -max-workers
- error opening %s: %s
AI-assisted analysis of tsenart/vegeta@cf58112690 (2026-08-31).
Data as JSON: /api/errors/f20c8b03b784f3ba.
Report an issue: GitHub.