{"record":{"id":"5ac53c5a6688caee","repo":"crowdsecurity/crowdsec","slug":"basic-auth-is-selected-but-basic-auth-is-not-prov","errorCode":null,"errorMessage":"basic_auth is selected, but basic_auth is not provided","messagePattern":"basic_auth is selected, but basic_auth is not provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/http/config.go","lineNumber":107,"sourceCode":"\ts.Config = cfg\n\n\treturn nil\n}\n\nfunc (c *Configuration) Validate() error {\n\tif c.ListenAddr == \"\" && c.ListenSocket == \"\" {\n\t\treturn errors.New(\"listen_addr or listen_socket is required\")\n\t}\n\n\tif c.Path[0] != '/' {\n\t\treturn errors.New(\"path must start with /\")\n\t}\n\n\tswitch c.AuthType {\n\tcase \"basic_auth\":\n\t\tbaseErr := \"basic_auth is selected, but\"\n\t\tif c.BasicAuth == nil {\n\t\t\treturn errors.New(baseErr + \" basic_auth is not provided\")\n\t\t}\n\n\t\tif c.BasicAuth.Username == \"\" {\n\t\t\treturn errors.New(baseErr + \" username is not provided\")\n\t\t}\n\n\t\tif c.BasicAuth.Password == \"\" {\n\t\t\treturn errors.New(baseErr + \" password is not provided\")\n\t\t}\n\tcase \"headers\":\n\t\tif c.Headers == nil {\n\t\t\treturn errors.New(\"headers is selected, but headers is not provided\")\n\t\t}\n\tcase \"mtls\":\n\t\tif c.TLS == nil || c.TLS.CaCert == \"\" {\n\t\t\treturn errors.New(\"mtls is selected, but ca_cert is not provided\")\n\t\t}\n\tdefault:","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/http/config.go#L89-L125","documentation":"When `auth_type: basic_auth` is set on an HTTP datasource, Validate() requires the `basic_auth` block (username/password pair) to be present. If c.BasicAuth is nil while c.AuthType == \"basic_auth\", it returns this composite error built from the baseErr prefix plus \" basic_auth is not provided\".","triggerScenarios":"Set `auth_type: basic_auth` in the http datasource config without a corresponding `basic_auth:` section, or with the section misspelled/nested incorrectly so it fails to unmarshal into c.BasicAuth, leaving it nil.","commonSituations":"Users enable basic_auth but forget to add credentials; YAML indentation places the basic_auth block outside the datasource; copying a config that uses header-based auth and changing only auth_type.","solutions":["Add a `basic_auth` block with `username` and `password` under the datasource config.","Check YAML indentation so `basic_auth:` is a sibling of `auth_type` inside the same datasource entry.","If basic auth is not actually needed, remove or change `auth_type`."],"exampleFix":"// before\nsource: http\nauth_type: basic_auth\n\n// after\nsource: http\nauth_type: basic_auth\nbasic_auth:\n  username: user\n  password: secret","handlingStrategy":"validation","validationCode":"if cfg.AuthType == \"basic_auth\" && cfg.BasicAuth == nil {\n    return errors.New(\"auth_type basic_auth requires a basic_auth block\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `basic_auth:` at the same YAML indentation level as `auth_type:`.","Pair every auth_type value with its required config block when writing configs.","Run `cscli` config validation or a startup dry-run before deploying."],"tags":["config","validation","authentication","basic-auth"],"backgroundTag":"missing-required-config-field","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"}