{"record":{"id":"d5f478e71a963548","repo":"crowdsecurity/crowdsec","slug":"data-source-type-is-empty","errorCode":null,"errorMessage":"data source type is empty","messagePattern":"data source type is empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/registry/registry.go","lineNumber":63,"sourceCode":"// It must be called in the init() function of the datasource package.\n// In addition, the build component is registered so it will be reported\n// by the \"cscli version / crowdsec --version\" commands.\nfunc RegisterFactory(module string, factory types.DataSourceFactory) {\n\tcomponent.Register(\"datasource_\" + module)\n\tregister(module, factory)\n}\n\n// RegisterTestFactory does not attempt to register it as a component,\n// production code should call RegisterFactory() instead and make the datasource\n// code optional using the appropriate build tag.\n// This function may be called outside init().\nfunc RegisterTestFactory(module string, factory types.DataSourceFactory) (restore func()) {\n\treturn register(module, factory)\n}\n\nfunc LookupFactory(module string) (types.DataSourceFactory, error) {\n\tif module == \"\" {\n\t\treturn nil, errors.New(\"data source type is empty\")\n\t}\n\n\tmu.RLock()\n\tfactory, registered := factoriesByName[module]\n\tmu.RUnlock()\n\n\tif registered {\n\t\treturn factory, nil\n\t}\n\n\tbuilt, known := component.Built[\"datasource_\"+module]\n\tif !known {\n\t\treturn nil, fmt.Errorf(\"unknown data source %s\", module)\n\t}\n\n\tif built {\n\t\tpanic(\"datasource \" + module + \" is built but not registered\")\n\t}","sourceCodeStart":45,"sourceCodeEnd":81,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/registry/registry.go#L45-L81","documentation":"The acquisition registry maps module names to their data-source factories. LookupFactory requires a non-empty module name; an empty string can never be registered, so it immediately fails with this error instead of a registry miss.","triggerScenarios":"Calling registry.LookupFactory(\"\") directly, or via Validate / DataSourceConfigure / LoadAcquisitionFromDSN when the parsed 'source:' key or DSN-derived type is an empty string.","commonSituations":"An acquisition YAML entry missing the 'source:' key; an empty source value after templating; a DSN parsed such that the module segment is blank.","solutions":["Set the 'source:' field in each acquisition config entry to a registered module (e.g. file, journalctl, wineventlog)","Check that templating/variable substitution produces a non-empty source name","Inspect the DSN prefix if using DSN-based loading and ensure it names a module"],"exampleFix":"# before\n---\nfilename: /var/log/syslog\n# after\n---\nsource: file\nfilename: /var/log/syslog","handlingStrategy":"validation","validationCode":"// Go: verify module name before registry lookup\nif moduleName == \"\" {\n    return fmt.Errorf(\"acquisition entry is missing a 'source:' field\")\n}\nif _, err := registry.LookupFactory(moduleName); err != nil {\n    return fmt.Errorf(\"unknown acquisition source %q: %w\", moduleName, err)\n}","typeGuard":null,"tryCatchPattern":"factory, err := registry.LookupFactory(module)\nif err != nil {\n    return fmt.Errorf(\"cannot resolve acquisition source: %w\", err)\n}","preventionTips":["Always set 'source:' in every acquisition config stanza","Lint acquisition YAML for empty required fields before deploy","Validate configs with cscli/crowdsec -t before restart"],"tags":["acquisition","registry","config"],"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"}