{"record":{"id":"e2a2b83c95f9b71d","repo":"crowdsecurity/crowdsec","slug":"leakspeed-is-required","errorCode":null,"errorMessage":"leakspeed is required","messagePattern":"leakspeed is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/leakybucket/buckettype.go","lineNumber":29,"sourceCode":"}\n\nvar bucketTypes = map[string]BucketType{\n\t\"leaky\":       LeakyType{},\n\t\"trigger\":     TriggerType{},\n\t\"counter\":     CounterType{},\n\t\"conditional\": ConditionalType{},\n\t\"bayesian\":    BayesianType{},\n}\n\ntype LeakyType struct{}\n\nfunc (LeakyType) Validate(f *BucketFactory) error {\n\tif f.Spec.Capacity <= 0 {\n\t\treturn fmt.Errorf(\"invalid capacity '%d': must be > 0\", f.Spec.Capacity)\n\t}\n\n\tif f.Spec.LeakSpeed == \"\" {\n\t\treturn errors.New(\"leakspeed is required\")\n\t}\n\n\tif f.leakspeed <= 0 {\n\t\treturn fmt.Errorf(\"invalid leakspeed '%s': must be > 0\", f.Spec.LeakSpeed)\n\t}\n\n\treturn nil\n}\n\nfunc (LeakyType) BuildProcessors(_ *BucketFactory) []Processor {\n\treturn []Processor{&DumbProcessor{}}\n}\n\ntype TriggerType struct{}\n\nfunc (TriggerType) Validate(f *BucketFactory) error {\n\tif f.Spec.Capacity != 0 {\n\t\treturn fmt.Errorf(\"invalid capacity '%d': must be 0\", f.Spec.Capacity)","sourceCodeStart":11,"sourceCodeEnd":47,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/leakybucket/buckettype.go#L11-L47","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\n# type: leaky\n# capacity: 5\n// after\n# type: leaky\n# capacity: 5\n# leakspeed: 10s","handlingStrategy":"validation","validationCode":"// before loading the bucket config\nif b.Spec.Type == \"leaky\" {\n    if b.Spec.Capacity <= 0 { return fmt.Errorf(\"capacity must be > 0\") }\n    if b.Spec.LeakSpeed == \"\" { return fmt.Errorf(\"leakspeed is required\") }\n    if _, err := time.ParseDuration(b.Spec.LeakSpeed); err != nil { return err }\n}","typeGuard":null,"tryCatchPattern":"if err := LeakyType{}.Validate(factory); err != nil {\n    if strings.Contains(err.Error(), \"leakspeed is required\") {\n        return fmt.Errorf(\"bucket %q: add a leakspeed like '10s' to the spec\", factory.Name)\n    }\n    return err\n}","preventionTips":["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"],"tags":["leakybucket","yaml-config","validation","crowdsec"],"backgroundTag":"missing-required-config-field","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}