{"record":{"id":"8fdd5a168b9315db","repo":"crowdsecurity/crowdsec","slug":"a-condition-is-required","errorCode":null,"errorMessage":"a condition is required","messagePattern":"a condition is required","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/leakybucket/buckettype.go","lineNumber":87,"sourceCode":"\t\treturn fmt.Errorf(\"invalid duration '%d': must be > 0\", f.duration)\n\t}\n\n\treturn nil\n}\n\nfunc (CounterType) BuildProcessors(_ *BucketFactory) []Processor {\n\treturn []Processor{&DumbProcessor{}}\n}\n\ntype ConditionalType struct{}\n\nfunc (ConditionalType) Validate(f *BucketFactory) error {\n\tif f.Spec.Capacity != -1 {\n\t\tf.logger.Warnf(\"Using a value different than -1 as capacity for conditional bucket, this may lead to unexpected overflows\")\n\t}\n\n\tif f.Spec.ConditionalOverflow == \"\" {\n\t\treturn errors.New(\"a condition is required\")\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 (ConditionalType) BuildProcessors(_ *BucketFactory) []Processor {\n\treturn []Processor{&DumbProcessor{}}\n}\n\ntype BayesianType struct{}","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/leakybucket/buckettype.go#L69-L105","documentation":"ConditionalType.Validate requires a conditional bucket to declare a `conditional_overflow` expression naming the bucket it overflows on. This error means that condition string is empty, so the bucket has no trigger and cannot be constructed.","triggerScenarios":"Loading a bucket with type: conditional whose spec lacks `conditional_overflow:` (f.Spec.ConditionalOverflow == \"\"), during bucket factory validation.","commonSituations":"Defining a conditional bucket for group-based alerting but forgetting to reference the feeder bucket's name; typos in the field name; copying a leaky bucket and changing only `type:`.","solutions":["Add the conditional_overflow expression referencing the feeder bucket, e.g. `conditional_overflow: my_feeder_bucket`","Also set a valid `leakspeed` (Validate checks it next, at buckettype.go:91)","Verify the referenced bucket name matches the feeder bucket's `name` field","Check YAML indentation so the field is inside the conditional bucket's spec"],"exampleFix":"// before\n# type: conditional\n# leakspeed: 10s\n// after\n# type: conditional\n# leakspeed: 10s\n# conditional_overflow: my_group_bucket","handlingStrategy":"validation","validationCode":"// before loading the bucket config\nif b.Spec.Type == \"conditional\" {\n    if b.Spec.ConditionalOverflow == \"\" { return fmt.Errorf(\"conditional_overflow is required\") }\n    if b.Spec.LeakSpeed == \"\" { return fmt.Errorf(\"leakspeed is required\") }\n}","typeGuard":null,"tryCatchPattern":"if err := ConditionalType{}.Validate(factory); err != nil {\n    if strings.Contains(err.Error(), \"a condition is required\") {\n        return fmt.Errorf(\"conditional bucket %q: set conditional_overflow to the feeder bucket name\", factory.Name)\n    }\n    return err\n}","preventionTips":["Always reference a feeder bucket by its `name` in conditional_overflow","Set leakspeed alongside conditional_overflow (it's checked immediately after)","Lint scenario YAML against the bucket schema before submission","Verify the feeder bucket exists in the same scenario"],"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"}