crowdsecurity/crowdsec · error

no parsers in hub index

Error message

no parsers in hub index

What it means

GetParsersCoverage requires the loaded hub index to contain parser items; when the hub index has no parsers (hub not loaded, empty, or wrong hubdir), coverage cannot be computed and the error is returned instead.

Solutions

  1. Run 'cscli hub update' (or re-clone the hub) to restore parser entries in the index
  2. Check the hubDir path points to a full hub checkout with parsers/ populated
  3. Validate the index loads: inspect HubIndex.GetItemMap(cwhub.PARSERS) length before coverage
Defensive patterns

Strategy: validation

Validate before calling

if len(h.HubIndex.GetItemMap(cwhub.PARSERS)) == 0 { return errors.New("hub index has no parsers; run hub update") }

Try / catch

if _, err := h.GetParsersCoverage(hubDir); err != nil { log.Fatalf("parser coverage unavailable: %v", err) }

Prevention

When it happens

Trigger: Calling HubTest.GetParsersCoverage(hubDir) against a hub index whose parsers map is empty — corrupted or partially downloaded index, or hub dir pointing at the wrong location.

Common situations: Misconfigured hub directory path in test harness; interrupted 'cscli hub update' leaving an index without parser entries.

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


AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06). Data as JSON: /api/errors/2b69833133fdbf18. Report an issue: GitHub.

Appendix: source

Thrown at pkg/hubtest/coverage.go:92

			}

			appsecRuleName := appsecRuleData.Name

			for idx, cov := range coverage {
				if cov.Name == appsecRuleName {
					coverage[idx].TestsCount++
					coverage[idx].PresentIn[appsecTestConfigPath] = true
				}
			}
		}
	}

	return coverage, nil
}

func (h *HubTest) GetParsersCoverage(hubDir string) ([]Coverage, error) {
	if len(h.HubIndex.GetItemMap(cwhub.PARSERS)) == 0 {
		return nil, errors.New("no parsers in hub index")
	}

	// populate from hub, iterate in alphabetical order
	pkeys := maptools.SortedKeys(h.HubIndex.GetItemMap(cwhub.PARSERS))
	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", "*", "parser.assert"))
	if err != nil {
		return nil, fmt.Errorf("while find parser asserts: %w", err)

View on GitHub (pinned to 909b515798)