crowdsecurity/crowdsec · error

parsing console config file '%s': %w

Error message

parsing console config file '%s': %w

What it means

The console configuration file (console.yaml) could not be unmarshalled from YAML into the console config struct. The file was read successfully; its content is malformed YAML or has a structure that does not match the expected schema.

Source

Thrown at pkg/csconfig/console.go:85

	if _, err := os.Stat(c.ConsoleConfigPath); err != nil && os.IsNotExist(err) {
		log.Debugf("no console configuration to load")

		c.ConsoleConfig.ShareCustomScenarios = new(true)
		c.ConsoleConfig.ShareTaintedScenarios = new(true)
		c.ConsoleConfig.ShareManualDecisions = new(false)
		c.ConsoleConfig.ShareContext = new(false)

		return nil
	}

	yamlFile, err := os.ReadFile(c.ConsoleConfigPath)
	if err != nil {
		return fmt.Errorf("reading console config file '%s': %w", c.ConsoleConfigPath, err)
	}

	err = yaml.Unmarshal(yamlFile, c.ConsoleConfig)
	if err != nil {
		return fmt.Errorf("parsing console config file '%s': %w", c.ConsoleConfigPath, err)
	}

	if c.ConsoleConfig.ShareCustomScenarios == nil {
		log.Debugf("no share_custom scenarios found, setting to true")
		c.ConsoleConfig.ShareCustomScenarios = new(true)
	}

	if c.ConsoleConfig.ShareTaintedScenarios == nil {
		log.Debugf("no share_tainted scenarios found, setting to true")
		c.ConsoleConfig.ShareTaintedScenarios = new(true)
	}

	if c.ConsoleConfig.ShareManualDecisions == nil {
		log.Debugf("no share_manual scenarios found, setting to false")
		c.ConsoleConfig.ShareManualDecisions = new(false)
	}

	if c.ConsoleConfig.ShareContext == nil {

View on GitHub (pinned to 909b515798)

Solutions

  1. Validate the file with a YAML linter (`yamllint /etc/crowdsec/console.yaml`)
  2. Fix values to booleans: share_custom_scenarios, share_tainted_scenarios, share_manual_decisions, share_context
  3. Replace tabs with spaces
  4. Restore the default file shipped with the package

Example fix

// before (console.yaml)
share_custom_scenarios:
	- true
// after
share_custom_scenarios: true
Defensive patterns

Strategy: validation

Validate before calling

var probe ConsoleConfig
if err := yaml.Unmarshal(rawConsoleYAML, &probe); err != nil {
	return fmt.Errorf("console.yaml invalid: %w", err)
}

Try / catch

if err := serverCfg.LoadConsoleConfig(); err != nil {
	if strings.Contains(err.Error(), "parsing console config file") {
		log.Fatalf("fix %s YAML: %v", serverCfg.ConsoleConfigPath, err)
	}
	return err
}

Prevention

When it happens

Trigger: console.yaml exists and is readable but contains invalid YAML (tabs, bad indentation) or wrong types like `share_custom_scenarios: "yes please"` instead of a boolean.

Common situations: Hand-editing console.yaml to toggle sharing options and breaking indentation; using tab characters; writing `true/false` with quotes or extra text; YAML anchors misused.

Related errors


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