{"record":{"id":"0d2320c64e577d3b","repo":"crowdsecurity/crowdsec","slug":"basic-auth-is-selected-but-username-is-not-provid","errorCode":null,"errorMessage":"basic_auth is selected, but username is not provided","messagePattern":"basic_auth is selected, but username is not provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/http/config.go","lineNumber":111,"sourceCode":"\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:\n\t\treturn errors.New(\"invalid auth_type: must be one of basic_auth, headers, mtls\")\n\t}\n\n\tif c.TLS != nil {","sourceCodeStart":93,"sourceCodeEnd":129,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/http/config.go#L93-L129","documentation":"With `auth_type: basic_auth` and a present `basic_auth` block, Validate() additionally requires a non-empty username. An empty c.BasicAuth.Username triggers this error: baseErr + \" username is not provided\".","triggerScenarios":"The `basic_auth` block exists but omits the `username` key, sets it to an empty string, or an env-var/template interpolation resolves to empty.","commonSituations":"Users fill in only the password; credentials pulled from a secrets file/env var where the username var is unset; partial copy-paste of a config snippet.","solutions":["Set `basic_auth.username` to the actual user name.","If the username comes from an env var, verify it is set and non-empty at load time.","Remove `auth_type: basic_auth` if basic auth is not required."],"exampleFix":"// before\nbasic_auth:\n  password: secret\n\n// after\nbasic_auth:\n  username: user\n  password: secret","handlingStrategy":"validation","validationCode":"if cfg.AuthType == \"basic_auth\" && (cfg.BasicAuth == nil || cfg.BasicAuth.Username == \"\") {\n    return errors.New(\"basic_auth requires a non-empty username\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always fill both username and password together when using basic_auth.","Verify env vars backing interpolated values are set in the deployment environment.","Keep credential templates complete; avoid deleting one half of the pair."],"tags":["config","validation","authentication","basic-auth"],"backgroundTag":"empty-required-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"}