{"record":{"id":"b702c07e2b431410","repo":"crowdsecurity/crowdsec","slug":"max-body-size-must-be-positive","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/http/config.go","lineNumber":140,"sourceCode":"\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}\n\n\tif c.MaxBodySize != nil && *c.MaxBodySize <= 0 {\n\t\treturn errors.New(\"max_body_size must be positive\")\n\t}\n\n\t/*\n\t\tif hc.ChunkSize != nil && *hc.ChunkSize <= 0 {\n\t\t\treturn errors.New(\"chunk_size must be positive\")\n\t\t}\n\t*/\n\n\tif c.CustomStatusCode != nil {\n\t\tstatusText := http.StatusText(*c.CustomStatusCode)\n\t\tif statusText == \"\" {\n\t\t\treturn errors.New(\"invalid HTTP status code\")\n\t\t}\n\t}\n\n\treturn nil\n}\n","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/acquisition/modules/http/config.go#L122-L158","documentation":"The optional max_body_size option of the http acquisition source was set to zero or a negative value. It controls the maximum accepted request body size (in bytes, after decompression; default 10 MiB), and Validate() rejects any non-positive value to prevent effectively-disabled or nonsensical limits.","triggerScenarios":"YAML config contains max_body_size: 0 or a negative number, or a templated/typed value that evaluates to <= 0 (e.g. an env placeholder expanding to 0, or a size-with-unit string misparsed). Raised by Configuration.Validate() (config.go:139-141).","commonSituations":"Users who want \"unlimited\" bodies set max_body_size: 0 instead of removing the option (no unlimited shortcut exists in validation); unit confusion — writing max_body_size: \"10MB\" where only an integer byte count is accepted by the schema; automation generating 0 when a variable is unset.","solutions":["Set max_body_size to a positive integer of bytes, e.g. max_body_size: 10485760 for 10 MiB","If you want the default (10 MiB), remove the max_body_size line entirely","Check that any templating/variable feeding this value resolves to a positive number","Remember SetDefaults() only applies the default when the value is absent — an explicit 0 is rejected, not defaulted"],"exampleFix":"# before\nsource: http\nlisten_addr: 127.0.0.1:8080\nauth_type: headers\nheaders:\n  X-Api-Key: secret\nmax_body_size: 0\n# after\nsource: http\nlisten_addr: 127.0.0.1:8080\nauth_type: headers\nheaders:\n  X-Api-Key: secret\nmax_body_size: 10485760","handlingStrategy":"validation","validationCode":"if cfg.MaxBodySize != nil && *cfg.MaxBodySize <= 0 {\n    return errors.New(\"max_body_size must be a positive integer (bytes)\")\n}","typeGuard":"func maxBodySizeValid(n *int64) bool {\n    return n == nil || *n > 0\n}","tryCatchPattern":"if _, err := httpacquisition.ConfigurationFromYAML(y); err != nil {\n    if strings.Contains(err.Error(), \"max_body_size must be positive\") {\n        return fmt.Errorf(\"bad max_body_size in acquisition config: %w\", err)\n    }\n    return err\n}","preventionTips":["Use positive byte values (e.g. 10485760); there is no 0 = unlimited shortcut","Omit max_body_size to get the 10 MiB default instead of setting it explicitly","Ensure only integer bytes are written — size strings like \"10MB\" are not accepted"],"tags":["crowdsec","http-acquisition","config-validation","numeric-range"],"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-14T00:17:10.932Z"}