{"record":{"id":"2b3506961d8eb90c","repo":"crowdsecurity/crowdsec","slug":"while-checking-console-context-path-w","errorCode":null,"errorMessage":"while checking console_context_path: %w","messagePattern":"while checking console_context_path: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/alertcontext/config.go","lineNumber":119,"sourceCode":"// LoadConsoleContext loads the context from the hub (if provided) and the file console_context_path.\nfunc LoadConsoleContext(c *csconfig.Config, hub *cwhub.Hub) error {\n\tc.Crowdsec.ContextToSend = make(map[string][]string, 0)\n\n\tif hub != nil {\n\t\tfor _, item := range hub.GetInstalledByType(cwhub.CONTEXTS, true) {\n\t\t\t// context in item files goes under the key 'context'\n\t\t\tif err := addContextFromItem(c.Crowdsec.ContextToSend, item); err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t}\n\t}\n\n\tignoreMissing := false\n\n\tif c.Crowdsec.ConsoleContextPath != \"\" {\n\t\t// if it's provided, it must exist\n\t\tif _, err := os.Stat(c.Crowdsec.ConsoleContextPath); err != nil {\n\t\t\treturn fmt.Errorf(\"while checking console_context_path: %w\", err)\n\t\t}\n\t} else {\n\t\tc.Crowdsec.ConsoleContextPath = filepath.Join(c.ConfigPaths.ConfigDir, \"console\", \"context.yaml\")\n\t\tignoreMissing = true\n\t}\n\n\tif err := addContextFromFile(c.Crowdsec.ContextToSend, c.Crowdsec.ConsoleContextPath); err != nil {\n\t\tif !errors.Is(err, fs.ErrNotExist) {\n\t\t\treturn err\n\t\t} else if !ignoreMissing {\n\t\t\tlog.Warningf(\"while merging context from %s: %s\", c.Crowdsec.ConsoleContextPath, err)\n\t\t}\n\t}\n\n\tfeedback, err := json.Marshal(c.Crowdsec.ContextToSend)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"serializing console context: %s\", err)\n\t}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/alertcontext/config.go#L101-L137","documentation":"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.","triggerScenarios":"Thrown at pkg/alertcontext/config.go:119 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Create the console context file at the configured path","Fix the console_context_path in config.yaml","Remove the option if no console context file is desired"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}