crowdsecurity/crowdsec · error
file %s: %s
Error message
file %s: %s
What it means
LoadFeatureFlagsFile reads the feature.yaml file and feeds it to fflag.Crowdsec.SetFromYamlFile, which parses and applies the feature flag definitions. Any parse/validation failure from that call is wrapped with the file path so the operator knows which file is broken. Until this succeeds, feature flags are not applied to the command run.
Source
Thrown at pkg/csconfig/fflag.go:32
func LoadFeatureFlagsEnv(logger *log.Logger) error {
return fflag.Crowdsec.SetFromEnv(logger)
}
// FeatureFlagsFileLocation returns the path to the feature.yaml file.
// The file is in the same directory as config.yaml, which is provided
// as the fist parameter. This can be different than ConfigPaths.ConfigDir
// because we have not read config.yaml yet so we don't know the value of ConfigDir.
func GetFeatureFilePath(configPath string) string {
dir := filepath.Dir(configPath)
return filepath.Join(dir, "feature.yaml")
}
// LoadFeatureFlags parses feature.yaml to enable feature flags.
func LoadFeatureFlagsFile(configPath string, logger *log.Logger) error {
featurePath := GetFeatureFilePath(configPath)
if err := fflag.Crowdsec.SetFromYamlFile(featurePath, logger); err != nil {
return fmt.Errorf("file %s: %s", featurePath, err)
}
return nil
}
// ListFeatureFlags returns a list of the enabled feature flags.
func ListFeatureFlags() string {
enabledFeatures := fflag.Crowdsec.GetEnabledFeatures()
msg := "none"
if len(enabledFeatures) > 0 {
msg = strings.Join(enabledFeatures, ", ")
}
return msg
}
View on GitHub (pinned to 909b515798)
Solutions
- Validate feature.yaml with `yamllint /etc/crowdsec/feature.yaml` to find syntax errors (tabs, bad indentation).
- Check flag names against the flags supported by your crowdsec version (`cscli version`); unknown flags in KnownFields mode fail parsing.
- Temporarily move feature.yaml away and rerun; then re-add flags one at a time to find the offending one.
- Restore a pristine copy of feature.yaml from upstream config and reapply your changes.
Example fix
// before (feature.yaml, tab indentation) alert: flush: // after alert: flush:
Defensive patterns
Strategy: try-catch
Validate before calling
if _, err := os.Stat(featurePath); err != nil {
log.Printf("feature.yaml missing at %s: %v", featurePath, err)
}
if data, err := os.ReadFile(featurePath); err == nil {
var v map[string]any
if err := yaml.Unmarshal(data, &v); err != nil {
log.Printf("feature.yaml invalid: %v", err)
}
} Try / catch
if err := csconfig.LoadFeatureFlagsFile(cfgPath, logger); err != nil {
logger.Printf("feature flags not applied: %v", err) // decide to abort or continue with defaults
} Prevention
- Lint feature.yaml with yamllint in CI before shipping config changes.
- Re-check feature names against the release notes on every crowdsec upgrade.
- Keep feature.yaml minimal — only flags you actually need.
When it happens
Trigger: feature.yaml at GetFeatureFilePath(configPath) contains invalid YAML, unknown field names, or a wrong value type for a flag — SetFromYamlFile rejects it and the error is wrapped here.
Common situations: Hand-edited feature.yaml with tabs instead of spaces, a flag name misspelled or removed in a newer crowdsec version, or a value given as a string where a boolean/list is expected.
Related errors
- failed to parse feature flags: %w
- empty file
- while parsing DockerAcquisition configuration: %s
- cannot parse FileAcquisition configuration: %s
- cannot parse: %s
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/19b1ff3df8113802.
Report an issue: GitHub.