{"record":{"id":"fd79e27bb77791b6","repo":"crowdsecurity/crowdsec","slug":"capacity-must-be-1","errorCode":null,"errorMessage":"capacity must be -1","messagePattern":"capacity must be -1","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/leakybucket/buckettype.go","lineNumber":121,"sourceCode":"}\n\ntype BayesianType struct{}\n\nfunc (BayesianType) Validate(f *BucketFactory) error {\n\tif len(f.Spec.BayesianConditions) == 0 {\n\t\treturn errors.New(\"bayesian conditions are required\")\n\t}\n\n\tif f.Spec.BayesianPrior <= 0 || f.Spec.BayesianPrior > 1 {\n\t\treturn errors.New(\"invalid prior: must be > 0 and <= 1\")\n\t}\n\n\tif f.Spec.BayesianThreshold == 0 || f.Spec.BayesianThreshold > 1 {\n\t\treturn errors.New(\"invalid threshold: must be > 0 and <= 1\")\n\t}\n\n\tif f.Spec.Capacity != -1 {\n\t\treturn errors.New(\"capacity must be -1\")\n\t}\n\n\treturn nil\n}\n\nfunc (BayesianType) BuildProcessors(_ *BucketFactory) []Processor {\n\treturn []Processor{&DumbProcessor{}}\n}\n","sourceCodeStart":103,"sourceCodeEnd":130,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/leakybucket/buckettype.go#L103-L130","documentation":"A bucket validated by this Bayesian Validate must have Capacity == -1, i.e. it must never leak by capacity; Bayesian buckets are purely probability-driven and cannot use the classic leaky-bucket capacity mechanism. Validate enforces this invariant at load time.","triggerScenarios":"Loading a Bayesian-type bucket config whose Spec.Capacity is set to any value other than -1 (e.g. capacity: 5 or capacity: 10).","commonSituations":"Copy-pasting a classic/leaky bucket YAML and only switching the type to bayesian, leaving capacity configured.","solutions":["Set `capacity: -1` in the bucket spec","Remove the capacity line entirely only if defaults yield -1; otherwise set it explicitly to -1","Use a classic (non-bayesian) bucket type if you actually need capacity-based leaking"],"exampleFix":"# before\ntype: bayesian\ncapacity: 10\n# after\ntype: bayesian\ncapacity: -1","handlingStrategy":"validation","validationCode":"if cfg.Type == \"bayesian\" && cfg.Capacity != -1 {\n    return fmt.Errorf(\"bayesian buckets require capacity: -1, got %d\", cfg.Capacity)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never copy `capacity:` into bayesian scenarios","Document bayesian scenarios with capacity: -1 in templates","Lint scenario files for type/capacity conflicts"],"tags":["crowdsec","leakybucket","config-validation","bayesian"],"backgroundTag":"invalid-config-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}