{"record":{"id":"b76a134af62b6e9c","repo":"crowdsecurity/crowdsec","slug":"invalid-hub-index-w-run-sudo-cscli-hub-update","errorCode":null,"errorMessage":"invalid hub index: %w. Run 'sudo cscli hub update' to download the index again","messagePattern":"invalid hub index: %w\\. Run 'sudo cscli hub update' to download the index again","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/hub.go","lineNumber":64,"sourceCode":"\tif logger == nil {\n\t\tlogger = logrus.New()\n\t\tlogger.SetOutput(io.Discard)\n\t}\n\n\thub := &Hub{\n\t\tlocal:  local,\n\t\tlogger: logger,\n\t}\n\n\treturn hub, nil\n}\n\n// Load reads the state of the items on disk.\nfunc (h *Hub) Load() error {\n\th.logger.Debugf(\"loading hub idx %s\", h.local.HubIndexFile)\n\n\tif err := h.parseIndex(); err != nil {\n\t\treturn fmt.Errorf(\"invalid hub index: %w. Run 'sudo cscli hub update' to download the index again\", err)\n\t}\n\n\treturn h.localSync()\n}\n\n// parseIndex takes the content of an index file and fills the map of associated parsers/scenarios/collections.\nfunc (h *Hub) parseIndex() error {\n\tbidx, err := os.ReadFile(h.local.HubIndexFile)\n\tif err != nil {\n\t\treturn fmt.Errorf(\"unable to read index file: %w\", err)\n\t}\n\n\tif err := json.Unmarshal(bidx, &h.items); err != nil {\n\t\treturn fmt.Errorf(\"failed to parse index: %w\", err)\n\t}\n\n\t// Iterate over the different types to complete the struct\n\tfor _, itemType := range ItemTypes {","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/hub.go#L46-L82","documentation":"Hub.Load wraps any error from parseIndex (unreadable, unparseable, or structurally invalid index) with remediation text telling the user to re-run `cscli hub update`. Load cannot proceed to localSync without a valid in-memory item map.","triggerScenarios":"Calling Hub.Load when the on-disk hub index file is missing, unreadable, invalid JSON, or contains entries with missing metadata (all parseIndex failure modes).","commonSituations":"First run before any `cscli hub update`, disk corruption, manual edits to .index.json, or upgrading crowdsec against an index written by an incompatible version.","solutions":["Run `sudo cscli hub update` to regenerate the index file","Inspect /var/lib/crowdsec/data/hub/.index.json validity (e.g. `jq . <file>`)","If unreadable/missing, check permissions and re-download via `cscli hub update`","Restore default hub data or reinstall if corruption persists"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"if _, err := os.Stat(hubIndexFile); err != nil {\n    return fmt.Errorf(\"hub index missing (%v); run 'cscli hub update' first\", err)\n}","typeGuard":null,"tryCatchPattern":"if err := hub.Load(); err != nil {\n    if strings.Contains(err.Error(), \"invalid hub index\") {\n        logger.Error(\"hub index invalid — running 'cscli hub update' then retrying\")\n        if rerr := runHubUpdate(ctx); rerr != nil { return rerr }\n        return hub.Load()\n    }\n    return err\n}","preventionTips":["Always run `cscli hub update` after install and before hub list/upgrade operations","Treat the index file as machine-managed; never edit it by hand","Re-download the index after any crowdsec version upgrade"],"tags":["hub","index","validation","config"],"backgroundTag":"schema-validation-failed","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"}