{"record":{"id":"60c0892f6dcdbeb9","repo":"crowdsecurity/crowdsec","slug":"couldn-t-find-custom-appsec-rule-s-in-the-follo","errorCode":null,"errorMessage":"couldn't find custom appsec-rule '%s' in the following location: %+v","messagePattern":"couldn't find custom appsec-rule '(.+?)' in the following location: %\\+v","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/appsecrule.go","lineNumber":84,"sourceCode":"\t\treturn false, fmt.Errorf(\"unable to copy appsec-rule from '%s' to '%s': %w\", customAppsecRulePath, customAppsecRuleDest, err)\n\t}\n\n\treturn true, nil\n}\n\nfunc (t *HubTestItem) installAppsecRuleCustom(appsecrule string) error {\n\tfor _, customPath := range t.CustomItemsLocation {\n\t\tfound, err := t.installAppsecRuleCustomFrom(appsecrule, customPath)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif found {\n\t\t\treturn nil\n\t\t}\n\t}\n\n\treturn fmt.Errorf(\"couldn't find custom appsec-rule '%s' in the following location: %+v\", appsecrule, t.CustomItemsLocation)\n}\n\nfunc (t *HubTestItem) installAppsecRule(name string) error {\n\tlog.Debugf(\"adding rule '%s'\", name)\n\n\tif item := t.HubIndex.GetItem(cwhub.APPSEC_RULES, name); item != nil {\n\t\treturn t.installAppsecRuleItem(item)\n\t}\n\n\treturn t.installAppsecRuleCustom(name)\n}\n","sourceCodeStart":66,"sourceCodeEnd":96,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/appsecrule.go#L66-L96","documentation":"installAppsecRuleCustom exhausts every directory in CustomItemsLocation without finding a file named after the requested custom appsec-rule, so the install fails. It distinguishes custom (non-hub) rules: the name was not found in the hub index nor in any custom location.","triggerScenarios":"installAppsecRule called with a name that is not a hub item (HubIndex.GetItem returns nil) and no file <name> exists under any of t.CustomItemsLocation paths.","commonSituations":"Typo in the rule name in the test .tests config; the custom rule file lives outside the configured CustomItemsLocation (e.g. not in .tests/ or the custom dir); rule file name differs from the name referenced in the test config.","solutions":["Confirm the file '<appsecrule>' exists in one of the CustomItemsLocation directories (paths are printed in the error)","Fix the rule name in the test config to match the file name exactly (including .yaml extension)","Add the rule file to the expected custom items directory used by the test"],"exampleFix":"# before: test config references 'my-custom-rule' but file missing\n.appsec-tests/  .tests/my-custom-rule.yaml -> references my-custom-rule (not present)\n# after\ncp my-custom-rule.yaml .tests/  # or rename to match referenced name","handlingStrategy":"validation","validationCode":"found := false\nfor _, dir := range t.CustomItemsLocation {\n\tif _, err := os.Stat(filepath.Join(dir, appsecrule)); err == nil {\n\t\tfound = true\n\t\tbreak\n\t}\n}\nif !found {\n\treturn fmt.Errorf(\"custom appsec-rule %q not in %v; fix name or location before install\", appsecrule, t.CustomItemsLocation)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep custom rule file names identical to the names referenced in test configs (including extension)","Store custom items inside the directories listed in CustomItemsLocation","Validate test .tests config rule names against the file listing before running tests"],"tags":["hub","test","custom-item","not-found"],"backgroundTag":"resource-not-found","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"}