{"record":{"id":"3370281c18062f77","repo":"crowdsecurity/crowdsec","slug":"no-hub-configuration-provided","errorCode":null,"errorMessage":"no hub configuration provided","messagePattern":"no hub configuration provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/cwhub/hub.go","lineNumber":43,"sourceCode":"\tWarnings []string // Warnings encountered during sync\n}\n\n// GetDataDir returns the data directory, where data sets are installed.\n// Empty for a hub created without local configuration (e.g. zero-value Hub in tests).\nfunc (h *Hub) GetDataDir() string {\n\tif h.local == nil {\n\t\treturn \"\"\n\t}\n\n\treturn h.local.InstallDataDir\n}\n\n// NewHub returns a new Hub instance with local and (optionally) remote configuration.\n// The hub is not synced automatically. Load() must be called to read the index, sync the local state,\n// and check for unmanaged items.\nfunc NewHub(local *csconfig.LocalHubCfg, logger *logrus.Logger) (*Hub, error) {\n\tif local == nil {\n\t\treturn nil, errors.New(\"no hub configuration provided\")\n\t}\n\n\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)","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/cwhub/hub.go#L25-L61","documentation":"NewHub constructs the cwhub Hub object and throws 'no hub configuration provided' when its *csconfig.LocalHubCfg argument is nil. The Hub cannot know where to read its index or item directories without local config, so construction fails immediately.","triggerScenarios":"Calling cwhub.NewHub(nil, logger) directly, or via callers (update, Hub, Serve, hubWithConfigs) when the LocalHubCfg was never built from config because the 'api.server' / hub config section is missing.","commonSituations":"Programmatic use of cwhub without loading csconfig first; loading a truncated/empty crowdsec config file so the hub section is absent; tools that call Hub before config load.","solutions":["Load and validate configuration before constructing the hub (cfg.LoadCrowdsecConfig / load the api.server section)","Pass a non-nil *csconfig.LocalHubCfg (e.g. cfg.Crowdsec.API.Server.Hub) to NewHub","In code, nil-check the config before calling NewHub and return a clearer configuration error"],"exampleFix":"// before\nhub, err := cwhub.NewHub(nil, logger)\n// after\nif localCfg == nil {\n    return fmt.Errorf(\"hub configuration missing; check config.yaml api.server section\")\n}\nhub, err := cwhub.NewHub(localCfg, logger)","handlingStrategy":"validation","validationCode":"if localCfg == nil { return errors.New(\"hub configuration missing: load config before cwhub.NewHub\") }","typeGuard":"func hubCfgReady(cfg *csconfig.Config) bool { return cfg != nil && cfg.Crowdsec != nil && cfg.Crowdsec.API != nil && cfg.Crowdsec.API.Server != nil && cfg.Crowdsec.API.Server.Hub != nil }","tryCatchPattern":"hub, err := cwhub.NewHub(localCfg, logger)\nif err != nil { return fmt.Errorf(\"failed to create hub: %w\", err) }","preventionTips":["Always load csconfig before constructing the Hub","Validate the config file contains the api.server/hub section at startup","Nil-check LocalHubCfg in wrapper functions that call NewHub"],"tags":["config","hub","nil","go"],"backgroundTag":"missing-required-argument","analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}