crowdsecurity/crowdsec · error
leakspeed is required
Error message
leakspeed is required
What it means
LeakyType.Validate enforces that a leaky-bucket configuration declares a positive capacity and a non-empty leak_speed. This error means the bucket spec parsed from the user's YAML has no leak_speed at all, so the bucket could never drain and cannot be constructed.
Source
Thrown at pkg/leakybucket/buckettype.go:29
}
var bucketTypes = map[string]BucketType{
"leaky": LeakyType{},
"trigger": TriggerType{},
"counter": CounterType{},
"conditional": ConditionalType{},
"bayesian": BayesianType{},
}
type LeakyType struct{}
func (LeakyType) Validate(f *BucketFactory) error {
if f.Spec.Capacity <= 0 {
return fmt.Errorf("invalid capacity '%d': must be > 0", f.Spec.Capacity)
}
if f.Spec.LeakSpeed == "" {
return errors.New("leakspeed is required")
}
if f.leakspeed <= 0 {
return fmt.Errorf("invalid leakspeed '%s': must be > 0", f.Spec.LeakSpeed)
}
return nil
}
func (LeakyType) BuildProcessors(_ *BucketFactory) []Processor {
return []Processor{&DumbProcessor{}}
}
type TriggerType struct{}
func (TriggerType) Validate(f *BucketFactory) error {
if f.Spec.Capacity != 0 {
return fmt.Errorf("invalid capacity '%d': must be 0", f.Spec.Capacity)View on GitHub (pinned to 909b515798)
Solutions
- Add a valid leakspeed to the bucket spec, e.g. `leakspeed: 10s`
- Re-validate the scenario with `cscli hubtest` or by reloading crowdsec and checking for this error
- Check for YAML indentation issues that push leakspeed outside the bucket's spec block
- Confirm the field name spelling: `leakspeed` (no underscore) under the bucket spec
Example fix
// before # type: leaky # capacity: 5 // after # type: leaky # capacity: 5 # leakspeed: 10s
Defensive patterns
Strategy: validation
Validate before calling
// before loading the bucket config
if b.Spec.Type == "leaky" {
if b.Spec.Capacity <= 0 { return fmt.Errorf("capacity must be > 0") }
if b.Spec.LeakSpeed == "" { return fmt.Errorf("leakspeed is required") }
if _, err := time.ParseDuration(b.Spec.LeakSpeed); err != nil { return err }
} Try / catch
if err := LeakyType{}.Validate(factory); err != nil {
if strings.Contains(err.Error(), "leakspeed is required") {
return fmt.Errorf("bucket %q: add a leakspeed like '10s' to the spec", factory.Name)
}
return err
} Prevention
- Always include leakspeed in every type: leaky bucket spec
- Lint scenario YAML against the bucket schema before submission
- Watch YAML indentation: leakspeed must be inside the bucket spec block
- Test custom scenarios with cscli hubtest before deploying
When it happens
Trigger: Loading a scenario/parsers YAML whose leaky bucket has type: leaky but omits the `leakspeed:` field (f.Spec.LeakSpeed == ""), during bucket factory validation at startup or scenario load.
Common situations: Hand-editing a scenario and deleting the leakspeed line; copying a bucket template and leaving leakspeed blank; a parsed-but-invalid duration string removed by tooling; hubtest of an incomplete custom scenario.
Understand the failure class
Background: "is required", "must be set", "missing required field": configuration validation errors across open-source libraries — this error's family across 36 libraries.
Related errors
- duration is required
- a condition is required
- bayesian conditions are required
- invalid prior: must be > 0 and <= 1
- path must start with /
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/e2a2b83c95f9b71d.
Report an issue: GitHub.