crowdsecurity/crowdsec · error

zero profiles loaded for LAPI

Error message

zero profiles loaded for LAPI

What it means

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.

Source

Thrown at pkg/csconfig/profiles.go:68

	dec.KnownFields(true)

	for {
		t := ProfileCfg{}

		err = dec.Decode(&t)
		if err != nil {
			if errors.Is(err, io.EOF) {
				break
			}

			return fmt.Errorf("while decoding %s: %w", c.ProfilesPath, err)
		}

		c.Profiles = append(c.Profiles, &t)
	}

	if len(c.Profiles) == 0 {
		return errors.New("zero profiles loaded for LAPI")
	}

	return nil
}

View on GitHub (pinned to 909b515798)

Solutions

  1. Restore at least one profile entry in profiles.yaml (copy config/profiles.yaml from the repo)
  2. Check any *.yaml.local override files next to profiles.yaml — remove ones that blank out the profiles
  3. Validate the file parses: ensure a top-level 'profiles:' key with at least one list item with name/filters/decisions

Example fix

// before (profiles.yaml)
profiles: []

// after
profiles:
  - name: default_deny
    filters:
      - Alert.Remediation == true
    decisions:
      - type: ban
        duration: 4h
Defensive patterns

Strategy: validation

Validate before calling

data, _ := os.ReadFile(profilesPath)
var p struct{ Profiles []map[string]any `yaml:"profiles"` }
if yaml.Unmarshal(data, &p) == nil && len(p.Profiles) == 0 {
    return fmt.Errorf("%s defines zero profiles; LAPI requires at least one", profilesPath)
}

Try / catch

if err := cfg.API.Server.LoadProfiles(); err != nil {
    if strings.Contains(err.Error(), "zero profiles") {
        log.Fatalf("profiles file %s has no entries; restore a default profile", cfg.API.Server.ProfilesPath)
    }
    return err
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.

Related errors


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/b88e6df97c904c63. Report an issue: GitHub.