{"record":{"id":"fc4122b68eac87de","repo":"crowdsecurity/crowdsec","slug":"errfeaturenameinvalid","errorCode":"ErrFeatureNameInvalid","errorMessage":"invalid name (allowed a-z, 0-9, _, .)","messagePattern":"invalid name \\(allowed a-z, 0-9, _, \\.\\)","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/fflag/features.go","lineNumber":45,"sourceCode":"package fflag\n\nimport (\n\t\"errors\"\n\t\"fmt\"\n\t\"io\"\n\t\"os\"\n\t\"regexp\"\n\t\"sort\"\n\t\"strings\"\n\n\t\"github.com/goccy/go-yaml\"\n\t\"github.com/sirupsen/logrus\"\n)\n\nvar (\n\tErrFeatureNameEmpty   = errors.New(\"name is empty\")\n\tErrFeatureNameCase    = errors.New(\"name is not lowercase\")\n\tErrFeatureNameInvalid = errors.New(\"invalid name (allowed a-z, 0-9, _, .)\")\n\tErrFeatureUnknown     = errors.New(\"unknown feature\")\n\tErrFeatureDeprecated  = errors.New(\"the flag is deprecated\")\n\tErrFeatureRetired     = errors.New(\"the flag is retired\")\n)\n\nconst (\n\tActiveState     = iota // the feature can be enabled, and its description is logged (Info)\n\tDeprecatedState        // the feature can be enabled, and a deprecation message is logged (Warning)\n\tRetiredState           // the feature is ignored and a deprecation message is logged (Error)\n)\n\ntype Feature struct {\n\tName  string\n\tState int // active, deprecated, retired\n\n\t// Description should be a short sentence, explaining the feature.\n\tDescription string\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/fflag/features.go#L27-L63","documentation":"Sentinel error ErrFeatureNameInvalid returned by validateFeatureName in pkg/fflag/features.go. Feature flag names must match featureNameRexp (a-z, 0-9, _, .); any other character (uppercase, dash, space, slash) is rejected before the name is looked up.","triggerScenarios":"Calling fflag Set/SetFromEnv/SetFromYaml/GetFeature with a name containing characters outside [a-z0-9_.], e.g. an env var mapped to a feature name with dashes or uppercase letters.","commonSituations":"Typo in feature flag name in config YAML or environment variable; copy-pasted names from another project using different naming conventions; manually crafted FFLAGS env value.","solutions":["Lowercase the feature name and replace invalid characters with _ or .","Run 'cscli features list' (or inspect pkg/fflag features list) to copy the exact allowed feature names","Check the env var value (e.g. CROWDSEC_FEATURES) for stray characters or quotes"],"exampleFix":"// before\nfeatureFlags.Set(\"Enable-Appsec\")\n// after\nfeatureFlags.Set(\"enable_appsec\")","handlingStrategy":"validation","validationCode":"var validName = regexp.MustCompile(`^[a-z0-9_.]+$`)\nif !validName.MatchString(name) { return fmt.Errorf(\"invalid feature name %q\", name) }","typeGuard":null,"tryCatchPattern":"if err := fflag.Set(name); errors.Is(err, fflag.ErrFeatureNameInvalid) { log.Warnf(\"bad feature name %q\", name) }","preventionTips":["Keep feature names lowercase with only a-z, 0-9, _ and .","Copy names from 'cscli features list' instead of typing them","Trim env var values before passing them as feature names"],"tags":["go","feature-flags","validation"],"backgroundTag":"invalid-identifier-format","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"}