{"record":{"id":"0aeb0f557b8b8b97","repo":"crowdsecurity/crowdsec","slug":"bayesian-conditions-are-required","errorCode":null,"errorMessage":"bayesian conditions are required","messagePattern":"bayesian conditions are required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/leakybucket/buckettype.go","lineNumber":109,"sourceCode":"\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 (ConditionalType) BuildProcessors(_ *BucketFactory) []Processor {\n\treturn []Processor{&DumbProcessor{}}\n}\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 {","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/leakybucket/buckettype.go#L91-L127","documentation":"BayesianType.Validate requires at least one Bayesian condition entry. This error means a bayesian bucket was declared with an empty `bayesian_conditions` list, so there is nothing to compute a posterior over and the bucket is rejected.","triggerScenarios":"Loading a bucket with type: bayesian whose spec has an empty or missing `bayesian_conditions:` list (len(f.Spec.BayesianConditions) == 0) during bucket factory validation.","commonSituations":"Writing a bayesian bucket for probabilistic alerting and leaving the conditions list empty; YAML indentation placing conditions outside the spec so they don't parse; all condition entries commented out.","solutions":["Add at least one condition with name and probability, e.g.\n# bayesian_conditions:\n#   - name: evt.MatchedCondition\n#     probability: 0.5","Check YAML indentation so bayesian_conditions is inside the bucket spec block","Un-comment any accidentally disabled condition entries","Also set valid bayesian_prior and bayesian_threshold (validated next)"],"exampleFix":"// before\n# type: bayesian\n# bayesian_conditions: []\n// after\n# type: bayesian\n# bayesian_conditions:\n#   - name: evt.LoginFailure\n#     probability: 0.6","handlingStrategy":"validation","validationCode":"// before loading the bucket config\nif b.Spec.Type == \"bayesian\" {\n    if len(b.Spec.BayesianConditions) == 0 { return fmt.Errorf(\"bayesian_conditions must list at least one condition\") }\n}","typeGuard":null,"tryCatchPattern":"if err := BayesianType{}.Validate(factory); err != nil {\n    if strings.Contains(err.Error(), \"bayesian conditions are required\") {\n        return fmt.Errorf(\"bayesian bucket %q: add at least one bayesian_conditions entry with name and probability\", factory.Name)\n    }\n    return err\n}","preventionTips":["Define conditions before the prior/threshold — they're validated first","Check YAML indentation so conditions parse inside the spec block","Don't comment out all condition entries when debugging","Test bayesian scenarios with cscli hubtest before deploying"],"tags":["leakybucket","bayesian","yaml-config","validation"],"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-14T05:17:10.506Z"}