crowdsecurity/crowdsec · error
couldn't find custom scenario '%s' in the following location
Error message
couldn't find custom scenario '%s' in the following location: %+v
What it means
installScenarioCustom looks for a custom scenario by name in each directory of t.CustomItemsLocation; if none contains it, this error is returned. The test referenced a custom scenario that isn't present in any of the configured custom locations and isn't in the hub index either.
Source
Thrown at pkg/hubtest/scenario.go:80
return false, fmt.Errorf("unable to copy scenario from '%s' to '%s': %w", customScenarioPath, scenarioFileDest, err)
}
return true, nil
}
func (t *HubTestItem) installScenarioCustom(scenario string) error {
for _, customPath := range t.CustomItemsLocation {
found, err := t.installScenarioCustomFrom(scenario, customPath)
if err != nil {
return err
}
if found {
return nil
}
}
return fmt.Errorf("couldn't find custom scenario '%s' in the following location: %+v", scenario, t.CustomItemsLocation)
}
func (t *HubTestItem) installScenario(name string) error {
if item := t.HubIndex.GetItem(cwhub.SCENARIOS, name); item != nil {
return t.installScenarioItem(item)
}
return t.installScenarioCustom(name)
}
View on GitHub (pinned to 909b515798)
Solutions
- Check the exact file name (with .yaml extension) against the requested scenario name.
- Place the custom scenario in one of the directories listed in the error's location output.
- Add the scenario's directory to CustomItemsLocation.
- If it's a hub scenario instead, install it via cscli so it resolves through the hub index.
Example fix
// before CustomItemsLocation: ["./custom-parsers"] // scenario is in ./custom-scenarios // after CustomItemsLocation: ["./custom-parsers", "./custom-scenarios"]
Defensive patterns
Strategy: validation
Validate before calling
found := false
for _, loc := range item.CustomItemsLocation {
if _, err := os.Stat(filepath.Join(loc, scenario+".yaml")); err == nil {
found = true
break
}
}
if !found {
// fail fast with a clear message before calling installScenario
} Try / catch
if err := t.installScenario(name); err != nil {
if strings.Contains(err.Error(), "couldn't find custom scenario") {
return fmt.Errorf("scenario %q not in hub or custom locations %v", name, t.CustomItemsLocation)
}
return err
} Prevention
- Match test-config scenario names exactly to file names.
- Register every custom scenario directory in CustomItemsLocation.
- Install hub scenarios with cscli before running tests that reference them.
When it happens
Trigger: installScenario is called with a name not found in the hub index, so installScenarioCustom is invoked, and no file matching the name exists in any CustomItemsLocation directory.
Common situations: Typo in the scenario name in test config; custom scenario stored outside the directories registered in CustomItemsLocation; scenario file renamed/deleted; running tests before cloning/copying the custom scenario into place.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- couldn't find custom postoverflow '%s' in the following loca
- can't get absolute path of '%s': %w
- no parser found. Please install the appropriate parser and r
- AverageInterval expects exactly one parameter: a slice of ti
- AverageInterval expects a slice of times
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/7f19db8f093a3f0f.
Report an issue: GitHub.