{"record":{"id":"ed0d3feac8c91fa0","repo":"crowdsecurity/crowdsec","slug":"while-loading-profiles-for-lapi-w","errorCode":null,"errorMessage":"while loading profiles for LAPI: %w","messagePattern":"while loading profiles for LAPI: %w","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"pkg/csconfig/api.go","lineNumber":426,"sourceCode":"\n\tif err := c.API.Server.LoadAutoRegister(); err != nil {\n\t\treturn err\n\t}\n\n\tif c.API.Server.AutoRegister != nil && c.API.Server.AutoRegister.Enable != nil && *c.API.Server.AutoRegister.Enable && !inCli {\n\t\tlog.Infof(\"auto LAPI registration enabled for ranges %+v\", c.API.Server.AutoRegister.AllowedRanges)\n\t}\n\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}","sourceCodeStart":408,"sourceCodeEnd":444,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/api.go#L408-L444","documentation":"LoadAPIServer wraps any error returned by LocalApiServerCfg.LoadProfiles() with this prefix. Profiles define automated decisions (tainted scenario defaults, etc.) loaded from profile.yaml files at LAPI startup; a parse, missing-file, or validation failure there aborts LAPI configuration loading.","triggerScenarios":"csconfig.LoadAPIServer is called during crowdsec startup (or `cscli` config load) and api.server.profiles points at a profile file that is missing, malformed YAML, or fails profile validation in LoadProfiles.","commonSituations":"Upgrading crowdsec with an old /etc/crowdsec/profile.yaml that no longer validates; hand-edited profile.yaml with wrong keys/types; config value profile_dir pointing to an empty or wrong directory; packaged profiles deleted by accident.","solutions":["Inspect the wrapped inner error to find the offending profile file and line","Restore the stock profile.yaml from the package or the GitHub repo (config/profile.yaml)","Fix YAML syntax / invalid keys in profile.yaml","Ensure api.server.profiles / profile paths in config.yaml point to existing files"],"exampleFix":"// before (config.yaml, broken)\napi:\n  server:\n    profiles_path: /etc/crowdsec/profile.yaml.bak\n// after\napi:\n  server:\n    profiles_path: /etc/crowdsec/profile.yaml","handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(profilesPath); os.IsNotExist(err) { log.Warn(\"profile file missing: \"+profilesPath) }","typeGuard":null,"tryCatchPattern":"if err := cfg.LoadAPIServer(); err != nil {\n\tif strings.Contains(err.Error(), \"while loading profiles for LAPI\") {\n\t\tlog.Fatalf(\"profile config invalid: %v — restore stock profile.yaml\", err)\n\t}\n\treturn err\n}","preventionTips":["Don't hand-edit profile.yaml; override behavior via console/central config","Keep the packaged profile.yaml intact across upgrades","Validate YAML after edits with yamllint"],"tags":["config","lapi","profiles","startup"],"backgroundTag":"config-file-not-found","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"}