crowdsecurity/crowdsec · error

while checking console_context_path: %w

Error message

while checking console_context_path: %w

What it means

LoadConsoleContext validates console_context_path with os.Stat when explicitly configured; the configured file cannot be accessed (missing or unreadable), so the console context cannot be loaded and crowdsec startup fails.

Source

Thrown at pkg/alertcontext/config.go:119

// LoadConsoleContext loads the context from the hub (if provided) and the file console_context_path.
func LoadConsoleContext(c *csconfig.Config, hub *cwhub.Hub) error {
	c.Crowdsec.ContextToSend = make(map[string][]string, 0)

	if hub != nil {
		for _, item := range hub.GetInstalledByType(cwhub.CONTEXTS, true) {
			// context in item files goes under the key 'context'
			if err := addContextFromItem(c.Crowdsec.ContextToSend, item); err != nil {
				return err
			}
		}
	}

	ignoreMissing := false

	if c.Crowdsec.ConsoleContextPath != "" {
		// if it's provided, it must exist
		if _, err := os.Stat(c.Crowdsec.ConsoleContextPath); err != nil {
			return fmt.Errorf("while checking console_context_path: %w", err)
		}
	} else {
		c.Crowdsec.ConsoleContextPath = filepath.Join(c.ConfigPaths.ConfigDir, "console", "context.yaml")
		ignoreMissing = true
	}

	if err := addContextFromFile(c.Crowdsec.ContextToSend, c.Crowdsec.ConsoleContextPath); err != nil {
		if !errors.Is(err, fs.ErrNotExist) {
			return err
		} else if !ignoreMissing {
			log.Warningf("while merging context from %s: %s", c.Crowdsec.ConsoleContextPath, err)
		}
	}

	feedback, err := json.Marshal(c.Crowdsec.ContextToSend)
	if err != nil {
		return fmt.Errorf("serializing console context: %s", err)
	}

View on GitHub (pinned to 909b515798)

Solutions

  1. Create the console context file at the configured path
  2. Fix the console_context_path in config.yaml
  3. Remove the option if no console context file is desired
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pkg/alertcontext/config.go:119 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/2b3506961d8eb90c. Report an issue: GitHub.