crowdsecurity/crowdsec · error
cannot create a %s reader with an empty list of broker addre
Error message
cannot create a %s reader with an empty list of broker addresses
What it means
After parsing the kafka source config, UnmarshalConfig requires at least one broker address in the 'brokers' list. An empty or missing brokers list means the reader has nothing to connect to, so configuration is rejected with this message (the %s is the source name, 'kafka').
Source
Thrown at pkg/acquisition/modules/kafka/config.go:56
type KafkaBatchConfiguration struct {
BatchMinBytes int `yaml:"min_bytes"`
BatchMaxBytes int `yaml:"max_bytes"`
BatchMaxWait time.Duration `yaml:"max_wait"`
BatchQueueSize int `yaml:"queue_size"`
CommitInterval time.Duration `yaml:"commit_interval"`
}
func (s *Source) UnmarshalConfig(yamlConfig []byte) error {
s.Config = Configuration{}
err := yaml.UnmarshalWithOptions(yamlConfig, &s.Config, yaml.Strict())
if err != nil {
return fmt.Errorf("cannot parse: %s", yaml.FormatError(err, false, false))
}
if len(s.Config.Brokers) == 0 {
return fmt.Errorf("cannot create a %s reader with an empty list of broker addresses", s.GetName())
}
if s.Config.Topic == "" {
return fmt.Errorf("cannot create a %s reader with an empty topic", s.GetName())
}
if s.Config.Mode == "" {
s.Config.Mode = configuration.TAIL_MODE
}
s.logger.Debugf("successfully parsed kafka configuration : %+v", s.Config)
return err
}
func (s *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Entry, metricsLevel metrics.AcquisitionMetricsLevel) error {
s.logger = logger
s.metricsLevel = metricsLevelView on GitHub (pinned to 909b515798)
Solutions
- Add at least one broker to the config: brokers: [kafka1:9092].
- If brokers come from templating/env, verify the variable is populated at render time.
- Ensure each entry is a host:port reachable from the crowdsec host.
- Remove empty-string entries from the brokers list.
Example fix
// before source: kafka topic: crowdsec // after source: kafka brokers: - localhost:9092 topic: crowdsec
Defensive patterns
Strategy: validation
Validate before calling
var kc struct {
Brokers []string `yaml:"brokers"`
}
if err := yaml.Unmarshal(yamlCfg, &kc); err != nil { return err }
nonEmpty := 0
for _, b := range kc.Brokers { if strings.TrimSpace(b) != "" { nonEmpty++ } }
if nonEmpty == 0 { return errors.New("kafka source requires at least one broker") } Try / catch
if err := source.UnmarshalConfig(cfg); err != nil {
if strings.Contains(err.Error(), "empty list of broker addresses") {
// inject brokers from env/templating and retry
}
} Prevention
- Always include at least one brokers entry in kafka acquis blocks
- Verify templated/env-provided broker values are non-empty at render time
- Reachability-check each host:port before deployment
When it happens
Trigger: Source.UnmarshalConfig receiving a kafka YAML block with no 'brokers' key, an empty list ('brokers: []'), or a list containing only empty strings.
Common situations: Minimal example configs copied without the brokers line; templating that left the brokers field empty; forgetting to configure brokers because topic was set.
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
- cannot parse: %s
- cannot create a %s reader with an empty topic
- cannot parse: %s
- invalid DSN %s for journalctl source, must start with journa
- unsupported key %s in journalctl DSN
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/585cf922483fe485.
Report an issue: GitHub.