crowdsecurity/crowdsec · error

bucket must have name

Error message

bucket must have name

What it means

BucketFactory.Validate requires Spec.Name to be non-empty; every bucket must carry a unique name used as its identifier, key material and in alert labels. An empty name means the config item is malformed and is rejected before registration.

Source

Thrown at pkg/leakybucket/manager_load.go:81

	Filename            string
	RunTimeFilter       *vm.Program         `json:"-"`
	RunTimeGroupBy      *vm.Program         `json:"-"`
	DataDir             string
	leakspeed           time.Duration       // internal representation of `Leakspeed`
	duration            time.Duration       // internal representation of `Duration`
	ret                 chan pipeline.Event // the bucket-specific output chan for overflows
	processors          []Processor         // processors is the list of hooks for pour/overflow/create (cf. uniq, blackhole etc.)
	scenarioHash        string
	Simulated           bool                // Set to true if the scenario instantiating the bucket was in the exclusion list
	orderEvent          bool
}

// we use one NameGenerator for all the future buckets
var seed = namegenerator.NewNameGenerator(time.Now().UTC().UnixNano())

func (f *BucketFactory) Validate() error {
	if f.Spec.Name == "" {
		return errors.New("bucket must have name")
	}

	if f.Spec.Description == "" {
		return errors.New("description is mandatory")
	}

	impl, ok := bucketTypes[f.Spec.Type]
	if !ok {
		return fmt.Errorf("unknown bucket type '%s'", f.Spec.Type)
	}

	if err := impl.Validate(f); err != nil {
		return fmt.Errorf("%s bucket: %w", f.Spec.Type, err)
	}

	return f.Spec.ScopeType.CompileFilter()
}

View on GitHub (pinned to 909b515798)

Solutions

  1. Add a non-empty `name:` to the scenario/bucket YAML
  2. Check template rendering or ingestion scripts aren't dropping the name
  3. Validate with `cscli hubtest` before deploying

Example fix

# before
type: leaky
filter: "evt.Meta.log_type == 'ssh_failed-auth'"
# after
type: leaky
name: crowdsecurity/ssh-bf
filter: "evt.Meta.log_type == 'ssh_failed-auth'"
Defensive patterns

Strategy: validation

Validate before calling

if bucket.Spec.Name == "" {
    return errors.New("scenario must define a non-empty name")
}

Prevention

When it happens

Trigger: Loading a bucket file whose `name:` field is missing or empty, typically via LoadBucket during hub/config load.

Common situations: Hand-written scenario YAML missing the name field, templating/rendering leaving `name: ''`, or a truncated config file.

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


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/89047be58bcaaa4a. Report an issue: GitHub.