{"record":{"id":"f2ae0e2d4dd33320","repo":"crowdsecurity/crowdsec","slug":"max-body-size-must-be-positive-f2ae0e","errorCode":null,"errorMessage":"max_body_size must be positive","messagePattern":"max_body_size must be positive","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/acquisition/modules/kubernetesaudit/config.go","lineNumber":80,"sourceCode":"\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\nfunc (c *Configuration) Normalize() {\n\tif c.WebhookPath != \"\" && c.WebhookPath[0] != '/' {\n\t\tc.WebhookPath = \"/\" + c.WebhookPath\n\t}\n}\n\nfunc (s *Source) Configure(_ context.Context, config []byte, logger *log.Entry, metricsLevel metrics.AcquisitionMetricsLevel) error {\n\ts.logger = logger\n\ts.metricsLevel = metricsLevel\n\n\terr := s.UnmarshalConfig(config)\n\tif err != nil {","sourceCodeStart":62,"sourceCodeEnd":98,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/kubernetesaudit/config.go#L62-L98","documentation":"The kubernetesaudit acquisition source validates its configuration before starting the webhook server. max_body_size limits the size of audit event payloads the HTTP webhook accepts; the source refuses to start with a non-positive value because it would reject every incoming event or misconfigure the body reader.","triggerScenarios":"Calling Validate() on a KubernetesAuditCfg whose MaxBodySize pointer is non-nil and points to a value <= 0, e.g. a YAML config with `max_body_size: 0` or a negative number, or programmatic construction with a zero/negative int.","commonSituations":"Users set max_body_size: 0 thinking it means 'unlimited', copy a config where the field was zeroed, or compute the value dynamically and get a non-positive result.","solutions":["Set max_body_size to a positive byte value (e.g. 10485760 for 10MB) in the kubernetesaudit YAML config","Remove the max_body_size key entirely to use the default size limit","Fix the code computing the value so it yields a positive integer"],"exampleFix":"// before\nmax_body_size: 0\n// after\nmax_body_size: 10485760","handlingStrategy":"validation","validationCode":"if cfg.MaxBodySize != nil && *cfg.MaxBodySize <= 0 {\n    return fmt.Errorf(\"max_body_size must be positive, got %d\", *cfg.MaxBodySize)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Treat 0 as 'unset' in configs; omit the key rather than zeroing it","Validate config at startup before deploying","Clamp computed sizes to a minimum positive value"],"tags":["config","validation","kubernetes","acquisition"],"backgroundTag":"invalid-config-value","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"}