{"record":{"id":"5283ef21462cc0b1","repo":"crowdsecurity/crowdsec","slug":"appsec-rule-name-is-empty-for-s","errorCode":null,"errorMessage":"appsec rule name is empty for %s","messagePattern":"appsec rule name is empty for (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/appsec/loader.go","lineNumber":34,"sourceCode":"\tappsecRules = make(map[string]AppsecCollectionConfig)\n\n\tfor _, hubAppsecRuleItem := range hub.GetInstalledByType(cwhub.APPSEC_RULES, false) {\n\t\tcontent, err := os.ReadFile(hubAppsecRuleItem.State.LocalPath)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"unable to read file %s : %s\", hubAppsecRuleItem.State.LocalPath, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tvar rule AppsecCollectionConfig\n\n\t\terr = yaml.UnmarshalStrict(content, &rule)\n\t\tif err != nil {\n\t\t\tlog.Warnf(\"unable to parse file %s : %s\", hubAppsecRuleItem.State.LocalPath, err)\n\t\t\tcontinue\n\t\t}\n\n\t\tif rule.Name == \"\" {\n\t\t\treturn fmt.Errorf(\"appsec rule name is empty for %s\", hubAppsecRuleItem.State.LocalPath)\n\t\t}\n\n\t\trule.hash = hubAppsecRuleItem.State.LocalHash\n\t\trule.version = hubAppsecRuleItem.Version\n\n\t\tlog.Infof(\"Adding %s to appsec rules\", rule.Name)\n\n\t\tappsecRules[rule.Name] = rule\n\t}\n\n\tif len(appsecRules) == 0 {\n\t\tlog.Debugf(\"No appsec rules found\")\n\t}\n\treturn nil\n}\n","sourceCodeStart":16,"sourceCodeEnd":50,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/appsec/loader.go#L16-L50","documentation":"LoadAppsecRules loads appsec rule collections from the hub and requires every rule to carry a non-empty Name. This error aborts loading when a parsed rule file has an empty `name:` field, because rules are registered and matched by name. It names the offending local file path.","triggerScenarios":"Loading an appsec rules file from the hub/local hub directory whose YAML front-matter or `name` field is empty, while other files parse fine (parse errors are warned and skipped; empty names are fatal).","commonSituations":"Hand-edited or locally added appsec rule files missing the `name:` key, corrupted hub downloads, or a custom rules file copied from an older format.","solutions":["Open the file named in the error and add a non-empty `name:` field to the rule","If it is a hub collection, run `cscli hub update` / reinstall the collection to restore intact files","Validate custom rules YAML before deploying (name set at top level of the rule document)","Remove or fix locally added files under the hub appsec rules path"],"exampleFix":"# before (rules.yaml)\nsecrets:\n  - ...   # no name key\n# after\nname: crowdsecurity/my-rules\nsecrets:\n  - ...","handlingStrategy":"validation","validationCode":"// before loading\ndata, _ := os.ReadFile(path)\nif !strings.Contains(string(data), \"name:\") {\n    return fmt.Errorf(\"%s missing name field\", path)\n}","typeGuard":null,"tryCatchPattern":"err := LoadAppsecRules(config)\nif err != nil {\n    log.Fatalf(\"appsec rules failed to load: %v\", err)\n}","preventionTips":["Always set `name:` in custom appsec rule files","Validate hub files after manual edits","Reinstall collections rather than hand-fixing hub files"],"tags":["appsec","config","hub","validation"],"backgroundTag":"empty-required-field","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"}