crowdsecurity/crowdsec · error

cannot parse: %s

Error message

cannot parse: %s

What it means

The HTTP acquisition module parses its YAML configuration with yaml.UnmarshalWithOptions(..., yaml.Strict()), so any unknown field, wrong type, or malformed YAML is rejected and returned as "cannot parse: %s" with the formatted yaml error. This is strict schema validation of the acquisition config.

Source

Thrown at pkg/acquisition/modules/http/config.go:44

	ListenAddr                        string            `yaml:"listen_addr"`
	ListenSocket                      string            `yaml:"listen_socket"`
	Path                              string            `yaml:"path"`
	AuthType                          string            `yaml:"auth_type"`
	BasicAuth                         *BasicAuthConfig  `yaml:"basic_auth"`
	Headers                           map[string]string `yaml:"headers"`
	TLS                               *TLSConfig        `yaml:"tls"`
	CustomStatusCode                  *int              `yaml:"custom_status_code"`
	CustomHeaders                     map[string]string `yaml:"custom_headers"`
	MaxBodySize                       *int64            `yaml:"max_body_size"`
	Timeout                           *time.Duration    `yaml:"timeout"`
	configuration.DataSourceCommonCfg                   `yaml:",inline"`
}

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

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

	cfg.SetDefaults()

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

	return cfg, nil
}

type BasicAuthConfig struct {
	Username string `yaml:"username"`
	Password string `yaml:"password"`
}

type TLSConfig struct {

View on GitHub (pinned to 909b515798)

Solutions

  1. Read the formatted yaml error after 'cannot parse: ' — it names the exact line and offending field.
  2. Fix the key name/indentation to match the documented http acquisition schema for your crowdsec version.
  3. Replace tabs with spaces in the YAML file.
  4. Check `cscli hub list`/docs for the schema version: fields added in newer releases fail on older binaries and vice versa.

Example fix

// before
source: http
listen_adress: 127.0.0.1  # typo
// after
source: http
listen_address: 127.0.0.1
Defensive patterns

Strategy: validation

Validate before calling

# lint YAML and check schema keys before deploying
python3 -c "import yaml,sys; yaml.safe_load(open(sys.argv[1]))" acquis.yaml
grep -nE 'listen_adress|tabbed' acquis.yaml

Try / catch

// surface the underlying yaml error detail
if err := parse(cfg); err != nil {
    log.Fatalf("acquis config: %v", err) // includes line/field from yaml.FormatError
}

Prevention

When it happens

Trigger: yaml.UnmarshalWithOptions with Strict() fails in ConfigurationFromYAML (called via UnmarshalConfig) — unknown keys, bad indentation, wrong value types.

Common situations: Typos in config keys (e.g. 'listen_adress' instead of 'listen_address'); tab characters instead of spaces; unsupported fields copied from an older/newer crowdsec version; wrong nesting of tls/auth_type options.

Related errors


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