{"record":{"id":"2b69833133fdbf18","repo":"crowdsecurity/crowdsec","slug":"no-parsers-in-hub-index","errorCode":null,"errorMessage":"no parsers in hub index","messagePattern":"no parsers in hub index","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/hubtest/coverage.go","lineNumber":92,"sourceCode":"\t\t\t}\n\n\t\t\tappsecRuleName := appsecRuleData.Name\n\n\t\t\tfor idx, cov := range coverage {\n\t\t\t\tif cov.Name == appsecRuleName {\n\t\t\t\t\tcoverage[idx].TestsCount++\n\t\t\t\t\tcoverage[idx].PresentIn[appsecTestConfigPath] = true\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn coverage, nil\n}\n\nfunc (h *HubTest) GetParsersCoverage(hubDir string) ([]Coverage, error) {\n\tif len(h.HubIndex.GetItemMap(cwhub.PARSERS)) == 0 {\n\t\treturn nil, errors.New(\"no parsers in hub index\")\n\t}\n\n\t// populate from hub, iterate in alphabetical order\n\tpkeys := maptools.SortedKeys(h.HubIndex.GetItemMap(cwhub.PARSERS))\n\tcoverage := make([]Coverage, len(pkeys))\n\n\tfor i, name := range pkeys {\n\t\tcoverage[i] = Coverage{\n\t\t\tName:       name,\n\t\t\tTestsCount: 0,\n\t\t\tPresentIn:  make(map[string]bool),\n\t\t}\n\t}\n\n\t// parser the expressions a-la-oneagain\n\tpasserts, err := filepath.Glob(filepath.Join(hubDir, \".tests\", \"*\", \"parser.assert\"))\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"while find parser asserts: %w\", err)","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/hubtest/coverage.go#L74-L110","documentation":"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.","triggerScenarios":"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.","commonSituations":"Misconfigured hub directory path in test harness; interrupted 'cscli hub update' leaving an index without parser entries.","solutions":["Run 'cscli hub update' (or re-clone the hub) to restore parser entries in the index","Check the hubDir path points to a full hub checkout with parsers/ populated","Validate the index loads: inspect HubIndex.GetItemMap(cwhub.PARSERS) length before coverage"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if len(h.HubIndex.GetItemMap(cwhub.PARSERS)) == 0 { return errors.New(\"hub index has no parsers; run hub update\") }","typeGuard":null,"tryCatchPattern":"if _, err := h.GetParsersCoverage(hubDir); err != nil { log.Fatalf(\"parser coverage unavailable: %v\", err) }","preventionTips":["Refresh the hub index before running coverage tests","Confirm hubDir points to a complete hub checkout","Check for interrupted hub update operations"],"tags":["go","hub","parsers","testing"],"backgroundTag":"empty-result-set","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"}