{"record":{"id":"709060e3a35b6d76","repo":"crowdsecurity/crowdsec","slug":"invalid-on-failure-for-s-s","errorCode":null,"errorMessage":"invalid 'on_failure' for '%s' : %s","messagePattern":"invalid 'on_failure' for '(.+?)' : (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/csprofiles/csprofiles.go","lineNumber":53,"sourceCode":"\n\t\truntime := &Runtime{}\n\n\t\txlog := logging.SubLogger(log.StandardLogger(), \"profile\", log.InfoLevel)\n\n\t\truntime.Logger = xlog.WithFields(log.Fields{\n\t\t\t\"type\": \"profile\",\n\t\t\t\"name\": profile.Name,\n\t\t})\n\n\t\truntime.RuntimeFilters = make([]*vm.Program, len(profile.Filters))\n\t\truntime.Cfg = profile\n\n\t\tif runtime.Cfg.OnSuccess != \"\" && runtime.Cfg.OnSuccess != \"continue\" && runtime.Cfg.OnSuccess != \"break\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid 'on_success' for '%s': %s\", profile.Name, runtime.Cfg.OnSuccess)\n\t\t}\n\n\t\tif runtime.Cfg.OnFailure != \"\" && runtime.Cfg.OnFailure != \"continue\" && runtime.Cfg.OnFailure != \"break\" && runtime.Cfg.OnFailure != \"apply\" {\n\t\t\treturn nil, fmt.Errorf(\"invalid 'on_failure' for '%s' : %s\", profile.Name, runtime.Cfg.OnFailure)\n\t\t}\n\n\t\tfor fIdx, filter := range profile.Filters {\n\t\t\tif runtimeFilter, err = expr.Compile(filter, exprhelpers.GetExprOptions(map[string]interface{}{\"Alert\": &models.Alert{}})...); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error compiling filter of '%s': %w\", profile.Name, err)\n\t\t\t}\n\n\t\t\truntime.RuntimeFilters[fIdx] = runtimeFilter\n\t\t\tif profile.Debug != nil && *profile.Debug {\n\t\t\t\truntime.Logger.Logger.SetLevel(log.DebugLevel)\n\t\t\t}\n\t\t}\n\n\t\tif profile.DurationExpr != \"\" {\n\t\t\tif runtimeDurationExpr, err = expr.Compile(profile.DurationExpr, exprhelpers.GetExprOptions(map[string]interface{}{\"Alert\": &models.Alert{}})...); err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"error compiling duration_expr of %s: %w\", profile.Name, err)\n\t\t\t}\n","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/csprofiles/csprofiles.go#L35-L71","documentation":"A profile in profiles.yaml declares an on_failure value that is neither \"continue\" nor \"break\" (nor empty). This is the on_failure sibling of the on_success check just above it in NewProfile; the offending profile name and value are echoed.","triggerScenarios":"Calling NewProfile with a profile config whose OnFailure field is a non-empty string other than \"continue\", \"break\", or \"apply\", e.g. \"stop\", \"abort\", \"apply_filters\".","commonSituations":"Typo in profiles.yaml on_failure; inventing values not in the accepted set; copy-paste from docs of an older CrowdSec version that did not support \"apply\".","solutions":["Set on_failure to one of \"continue\", \"break\", or \"apply\".","Remove the on_failure key to fall back to the default (continue).","Upgrade CrowdSec if you intended \"apply\" but run a version where it is not accepted (it is valid in current code)."],"exampleFix":"// before\nname: my-profile\non_failure: stop\n// after\nname: my-profile\non_failure: apply","handlingStrategy":"validation","validationCode":"var validOnFailure = map[string]bool{\"\": true, \"continue\": true, \"break\": true, \"apply\": true}\nfunc onFailureValid(v string) bool { return validOnFailure[v] }","typeGuard":null,"tryCatchPattern":"if _, err := csprofiles.NewProfile(cfgs, ...); err != nil {\n\tif strings.Contains(err.Error(), \"invalid 'on_failure'\") { /* correct the on_failure value */ }\n}","preventionTips":["Only use \"continue\", \"break\", or \"apply\" for on_failure","Omit the key to use the default behavior","Validate profiles.yaml after upgrading CrowdSec versions"],"tags":["profiles","configuration","validation"],"backgroundTag":"invalid-enum-value","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}