crowdsecurity/crowdsec · error
no scenarios in hub index
Error message
no scenarios in hub index
What it means
Raised by GetScenariosCoverage when the loaded hub index contains no scenario items, so scenario coverage cannot be computed — the hub index is empty or wasn't refreshed before running hubtest coverage.
Source
Thrown at pkg/hubtest/coverage.go:178
if capturedParserName == parserNameOnly+"-logs" {
coverage[idx].TestsCount++
coverage[idx].PresentIn[assert] = true
continue
}
}
}
file.Close()
}
return coverage, nil
}
func (h *HubTest) GetScenariosCoverage(hubDir string) ([]Coverage, error) {
if len(h.HubIndex.GetItemMap(cwhub.SCENARIOS)) == 0 {
return nil, errors.New("no scenarios in hub index")
}
// populate from hub, iterate in alphabetical order
pkeys := maptools.SortedKeys(h.HubIndex.GetItemMap(cwhub.SCENARIOS))
coverage := make([]Coverage, len(pkeys))
for i, name := range pkeys {
coverage[i] = Coverage{
Name: name,
TestsCount: 0,
PresentIn: make(map[string]bool),
}
}
// parser the expressions a-la-oneagain
passerts, err := filepath.Glob(filepath.Join(hubDir, ".tests", "*", "scenario.assert"))
if err != nil {
return nil, fmt.Errorf("while find scenario asserts: %w", err)View on GitHub (pinned to 909b515798)
Solutions
- Refresh the hub index ('cscli hub update') so scenarios are indexed
- Point the test harness at a complete crowdsec hub checkout
- Guard the call: skip scenario coverage if the index has no scenarios
Defensive patterns
Strategy: validation
Validate before calling
if len(h.HubIndex.GetItemMap(cwhub.SCENARIOS)) == 0 { return errors.New("hub index has no scenarios; run hub update") } Try / catch
if _, err := h.GetScenariosCoverage(hubDir); err != nil { log.Fatalf("scenario coverage unavailable: %v", err) } Prevention
- Update the hub index before scenario coverage runs
- Use a full crowdsec hub, not a stripped-down fork
- Assert non-empty scenario map in test setup
When it happens
Trigger: Calling HubTest.GetScenariosCoverage(hubDir) after loading a hub index with no scenarios — stale index or hub directory lacking the scenarios collection.
Common situations: Test environments pointed at a minimal/custom hub without scenarios; hub index file truncated or from a stripped-down fork.
Understand the failure class
Background: EmptyResultError / "no results found": when an API or scraper succeeds but returns zero rows — this error's family across 9 libraries.
Related errors
- no appsec rules in hub index
- no parsers in hub index
- no hub configuration provided
- ErrUserCanceled
- ErrNucleiTemplateFail
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/98330e94f8a99d3d.
Report an issue: GitHub.