{"record":{"id":"ef1ae23b43ae93d2","repo":"crowdsecurity/crowdsec","slug":"listen-addr-cannot-be-empty","errorCode":null,"errorMessage":"listen_addr cannot be empty","messagePattern":"listen_addr cannot be empty","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kubernetesaudit/config.go","lineNumber":68,"sourceCode":"\tif c.MaxBodySize == nil {\n\t\tc.MaxBodySize = new(defaultMaxBodySize)\n\t}\n}\n\nfunc (s *Source) UnmarshalConfig(yamlConfig []byte) error {\n\tcfg, err := ConfigurationFromYAML(yamlConfig)\n\tif err != nil {\n\t\treturn err\n\t}\n\n\ts.config = cfg\n\n\treturn nil\n}\n\nfunc (c *Configuration) Validate() error {\n\tif c.ListenAddr == \"\" {\n\t\treturn errors.New(\"listen_addr cannot be empty\")\n\t}\n\n\tif c.ListenPort == 0 {\n\t\treturn errors.New(\"listen_port cannot be empty\")\n\t}\n\n\tif c.WebhookPath == \"\" {\n\t\treturn errors.New(\"webhook_path cannot be empty\")\n\t}\n\n\tif c.MaxBodySize != nil && *c.MaxBodySize <= 0 {\n\t\treturn errors.New(\"max_body_size must be positive\")\n\t}\n\n\treturn nil\n}\n\n","sourceCodeStart":50,"sourceCodeEnd":86,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kubernetesaudit/config.go#L50-L86","documentation":"The kubernetesaudit source runs an HTTP server to receive audit webhook events, so it must know which address to bind. Configuration.Validate() rejects an empty ListenAddr because without it the audit server cannot be started.","triggerScenarios":"Calling Validate() on a kubernetesaudit Configuration where ListenAddr is the empty string — usually a YAML config missing the `listen_addr:` key.","commonSituations":"A minimal acquisition file with only source: kubernetesaudit and port set, or a config copied from docs that expects a default address which does not exist.","solutions":["Set listen_addr in the acquisition YAML, e.g. listen_addr: 0.0.0.0 (or 127.0.0.1 for local-only).","Provide both listen_addr and listen_port together; port alone is not sufficient.","Validate the config before restarting crowdsec so the audit webhook is reachable."],"exampleFix":"// before (yaml)\nsource: kubernetesaudit\nlisten_port: 8080\n\n// after (yaml)\nsource: kubernetesaudit\nlisten_addr: 0.0.0.0\nlisten_port: 8080","handlingStrategy":"validation","validationCode":"if cfg.ListenAddr == \"\" {\n    return fmt.Errorf(\"kubernetesaudit: listen_addr is required\")\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always set listen_addr and listen_port together in kubernetesaudit configs.","Use 127.0.0.1 when the API server runs on the same node, 0.0.0.0 for external access.","Validate acquisition YAML before restarting crowdsec."],"tags":["kubernetes","audit","config-validation","webhook"],"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-14T00:17:10.932Z"}