crowdsecurity/crowdsec · error

cannot parse: %s

Error message

cannot parse: %s

What it means

Returned by ConfigurationFromYAML when strict YAML unmarshalling of the kubernetes acquisition configuration fails — for example unknown fields or wrong value types in the datasource YAML. Wraps the underlying yaml error and names the offending config blob.

Source

Thrown at pkg/acquisition/modules/kubernetes/config.go:31

	"github.com/crowdsecurity/crowdsec/pkg/acquisition/configuration"
	"github.com/crowdsecurity/crowdsec/pkg/metrics"
)

type Configuration struct {
	configuration.DataSourceCommonCfg `yaml:",inline"`

	Selector       string `yaml:"selector"`
	Namespace      string `yaml:"namespace"`
	KubeConfigFile string `yaml:"kube_config,omitempty"`
	KubeContext    string `yaml:"kube_context,omitempty"`
}

func ConfigurationFromYAML(yamlConfig []byte) (Configuration, error) {
	var cfg Configuration

	if err := yaml.UnmarshalWithOptions(yamlConfig, &cfg, yaml.Strict()); err != nil {
		return cfg, fmt.Errorf("cannot parse: %s", yaml.FormatError(err, false, false))
	}

	cfg.SetDefaults()

	if err := cfg.Validate(); err != nil {
		return cfg, err
	}

	return cfg, nil
}

func (c *Configuration) SetDefaults() {
	if c.Namespace == "" {
		c.Namespace = "default"
	}

	if c.Mode == "" {
		c.Mode = configuration.TAIL_MODE

View on GitHub (pinned to 909b515798)

Solutions

  1. Fix YAML syntax errors reported after 'cannot parse'
  2. Remove unknown/misspelled keys — strict mode rejects them
  3. Compare against documented kubernetes source configuration
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/acquisition/modules/kubernetes/config.go:31 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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