{"record":{"id":"c00484b89186afc5","repo":"crowdsecurity/crowdsec","slug":"headers-is-selected-but-headers-is-not-provided","errorCode":null,"errorMessage":"headers is selected, but headers is not provided","messagePattern":"headers is selected, but headers is not provided","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/http/config.go","lineNumber":119,"sourceCode":"\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 {\n\t\tif c.TLS.ServerCert == \"\" {\n\t\t\treturn errors.New(\"server_cert is required\")\n\t\t}\n\n\t\tif c.TLS.ServerKey == \"\" {\n\t\t\treturn errors.New(\"server_key is required\")\n\t\t}\n\t}","sourceCodeStart":101,"sourceCodeEnd":137,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/http/config.go#L101-L137","documentation":"When `auth_type: headers` is selected, Validate() requires the `headers` map to be present. If c.Headers is nil, it returns \"headers is selected, but headers is not provided\". The auth type declares intent that the config does not back with data.","triggerScenarios":"Set `auth_type: headers` without a `headers:` section, or with the section misnamed/mis-indented so it unmarshals to nil.","commonSituations":"Users switch from basic_auth to header auth and forget to add the headers block; YAML indentation nests headers under another key; API-key authentication setups where the header block was deleted during editing.","solutions":["Add a `headers` map with at least one entry, e.g. `headers: {X-API-Key: mykey}`.","Check YAML indentation so `headers:` sits inside the same datasource entry as `auth_type`.","Remove or change `auth_type` if header auth is not needed."],"exampleFix":"// before\nsource: http\nauth_type: headers\n\n// after\nsource: http\nauth_type: headers\nheaders:\n  X-API-Key: mykey","handlingStrategy":"validation","validationCode":"if cfg.AuthType == \"headers\" && len(cfg.Headers) == 0 {\n    return errors.New(\"auth_type headers requires a non-empty headers map\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Add the headers block whenever you set auth_type: headers.","Check YAML nesting so `headers:` belongs to the datasource entry.","Validate the full datasource config with a dry run before rollout."],"tags":["config","validation","authentication","headers"],"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"}