{"record":{"id":"b88e6df97c904c63","repo":"crowdsecurity/crowdsec","slug":"zero-profiles-loaded-for-lapi","errorCode":null,"errorMessage":"zero profiles loaded for LAPI","messagePattern":"zero profiles loaded for LAPI","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csconfig/profiles.go","lineNumber":68,"sourceCode":"\tdec.KnownFields(true)\n\n\tfor {\n\t\tt := ProfileCfg{}\n\n\t\terr = dec.Decode(&t)\n\t\tif err != nil {\n\t\t\tif errors.Is(err, io.EOF) {\n\t\t\t\tbreak\n\t\t\t}\n\n\t\t\treturn fmt.Errorf(\"while decoding %s: %w\", c.ProfilesPath, err)\n\t\t}\n\n\t\tc.Profiles = append(c.Profiles, &t)\n\t}\n\n\tif len(c.Profiles) == 0 {\n\t\treturn errors.New(\"zero profiles loaded for LAPI\")\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":50,"sourceCodeEnd":73,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csconfig/profiles.go#L50-L73","documentation":"After unmarshaling the profiles file, LoadProfiles validates that at least one profile was parsed. Zero profiles means LAPI would emit alerts that never get any notification/remediation applied, which the configuration layer treats as invalid. This fires only when ProfilesPath was set but the parsed content produced no entries.","triggerScenarios":"profiles_path points at a file containing only comments or local overrides that replace all content (e.g. a .local override emptying the list); a profiles.yaml whose top-level 'profiles:' list is absent or empty; a file that parses as empty YAML after patching.","commonSituations":"Users truncating profiles.yaml to silence unwanted notifications, then breaking LAPI startup; malformed indentation making the profiles list fail to parse into entries; .local patch files accidentally overriding the default profiles away.","solutions":["Restore at least one profile entry in profiles.yaml (copy config/profiles.yaml from the repo)","Check any *.yaml.local override files next to profiles.yaml — remove ones that blank out the profiles","Validate the file parses: ensure a top-level 'profiles:' key with at least one list item with name/filters/decisions"],"exampleFix":"// before (profiles.yaml)\nprofiles: []\n\n// after\nprofiles:\n  - name: default_deny\n    filters:\n      - Alert.Remediation == true\n    decisions:\n      - type: ban\n        duration: 4h","handlingStrategy":"validation","validationCode":"data, _ := os.ReadFile(profilesPath)\nvar p struct{ Profiles []map[string]any `yaml:\"profiles\"` }\nif yaml.Unmarshal(data, &p) == nil && len(p.Profiles) == 0 {\n    return fmt.Errorf(\"%s defines zero profiles; LAPI requires at least one\", profilesPath)\n}","typeGuard":null,"tryCatchPattern":"if err := cfg.API.Server.LoadProfiles(); err != nil {\n    if strings.Contains(err.Error(), \"zero profiles\") {\n        log.Fatalf(\"profiles file %s has no entries; restore a default profile\", cfg.API.Server.ProfilesPath)\n    }\n    return err\n}","preventionTips":["Never reduce profiles.yaml to an empty list; disable a profile by adjusting its filters instead","Audit *.yaml.local overrides that could empty the profiles list","Validate profiles YAML in CI with a yaml.Unmarshal smoke test"],"tags":["config","lapi","profiles","validation"],"backgroundTag":"empty-result-set","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"}