{"record":{"id":"ea1c0b12ce22345e","repo":"crowdsecurity/crowdsec","slug":"while-loading-console-options-w","errorCode":null,"errorMessage":"while loading console options: %w","messagePattern":"while loading console options: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/api.go","lineNumber":434,"sourceCode":"\n\tif c.API.Server.UseForwardedForHeaders && c.API.Server.TrustedProxies == nil {\n\t\tc.API.Server.TrustedProxies = &[]string{\"0.0.0.0/0\"}\n\t}\n\n\tif c.API.Server.TrustedProxies != nil {\n\t\tc.API.Server.UseForwardedForHeaders = true\n\t}\n\n\tif err := c.API.Server.LoadProfiles(); err != nil {\n\t\treturn fmt.Errorf(\"while loading profiles for LAPI: %w\", err)\n\t}\n\n\tif c.API.Server.ConsoleConfigPath == \"\" {\n\t\tc.API.Server.ConsoleConfigPath = DefaultConsoleConfigFilePath\n\t}\n\n\tif err := c.API.Server.LoadConsoleConfig(); err != nil {\n\t\treturn fmt.Errorf(\"while loading console options: %w\", err)\n\t}\n\n\tif c.API.CTI != nil {\n\t\tif err := c.API.CTI.Load(); err != nil {\n\t\t\treturn fmt.Errorf(\"loading CTI configuration: %w\", err)\n\t\t}\n\t}\n\n\treturn nil\n}\n\n// we cannot unmarshal to type net.IPNet, so we need to do it manually\ntype capiWhitelists struct {\n\tIps   []string `yaml:\"ips\"`\n\tCidrs []string `yaml:\"cidrs\"`\n}\n\nfunc parseCapiWhitelists(fd io.Reader) (*CapiWhitelist, error) {","sourceCodeStart":416,"sourceCodeEnd":452,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/api.go#L416-L452","documentation":"LoadAPIServer calls LocalApiServerCfg.LoadConsoleConfig() after resolving the console config path. This wraps any error other than 'file does not exist' (which is tolerated with defaults) — i.e. the console.yaml file exists but cannot be read or parsed.","triggerScenarios":"crowdsec startup with api.server.console_config_path (default config/console.yaml) present on disk but unreadable (permissions) or invalid YAML.","commonSituations":"console.yaml owned by root with restrictive mode while crowdsec runs as the crowdsec user; hand-edited console.yaml with bad YAML indentation; a directory exists at the console_config_path location.","solutions":["Check permissions on the console config file (readable by the crowdsec user)","Validate the YAML (e.g. `yamllint /etc/crowdsec/config/console.yaml`)","Remove or rename the file — a missing file is accepted and defaults are used","Point api.server.console_config_path to a valid file"],"exampleFix":"// before\nsudo chown root:root /etc/crowdsec/console.yaml && sudo chmod 600 /etc/crowdsec/console.yaml\n// after\nsudo chown crowdsec:crowdsec /etc/crowdsec/console.yaml && sudo chmod 640 /etc/crowdsec/console.yaml","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(consolePath); err == nil {\n\tf, e := os.Open(consolePath); if e != nil { log.Warn(\"console.yaml unreadable: \"+e.Error()) } else { f.Close() }\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadAPIServer(); err != nil {\n\tvar pe *os.PathError\n\tif errors.As(err, &pe) && strings.Contains(err.Error(), \"console options\") {\n\t\tlog.Warnf(\"console config unreadable (%v), continuing with defaults\", pe)\n\t\treturn nil\n\t}\n\treturn err\n}","preventionTips":["Leave console.yaml absent if you don't use console sharing — defaults apply","Keep ownership crowdsec:crowdsec and mode 640","Run `cscli config check` after manual edits"],"tags":["config","lapi","console","yaml"],"backgroundTag":"file-read-failed","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"}