crowdsecurity/crowdsec · error
chunk_size must be positive
Error message
chunk_size must be positive
What it means
The HTTP acquisition source validates that body/size configuration values are sane. A chunk_size (or max_body_size) of zero or negative is meaningless for reading a stream, so validation rejects it before the source is started. Note in the current source the chunk_size check itself is commented out in pkg/acquisition/modules/http/config.go:145, so this message is only thrown by builds/revisions where that validation is active; max_body_size is still checked.
Source
Thrown at pkg/acquisition/modules/http/config.go:145
}
if c.TLS != nil {
if c.TLS.ServerCert == "" {
return errors.New("server_cert is required")
}
if c.TLS.ServerKey == "" {
return errors.New("server_key is required")
}
}
if c.MaxBodySize != nil && *c.MaxBodySize <= 0 {
return errors.New("max_body_size must be positive")
}
/*
if hc.ChunkSize != nil && *hc.ChunkSize <= 0 {
return errors.New("chunk_size must be positive")
}
*/
if c.CustomStatusCode != nil {
statusText := http.StatusText(*c.CustomStatusCode)
if statusText == "" {
return errors.New("invalid HTTP status code")
}
}
return nil
}
func (s *Source) Configure(_ context.Context, yamlConfig []byte, logger *log.Entry, metricsLevel metrics.AcquisitionMetricsLevel) error {
s.logger = logger
s.metricsLevel = metricsLevel
err := s.UnmarshalConfig(yamlConfig)View on GitHub (pinned to 909b515798)
Solutions
- Set chunk_size/max_body_size to a positive integer (e.g. max_body_size: 10M equivalent in bytes) in the http source YAML config.
- Remove the key entirely if you want the default — an unset (nil) value passes validation.
- If 0/-1 came from a template variable, check the variable resolution; quote and validate values before rendering the config.
Example fix
// before (acquis.yaml) source: http max_body_size: 0 // after source: http max_body_size: 10485760 # 10MB, must be > 0
Defensive patterns
Strategy: validation
Validate before calling
if cfg.MaxBodySize != nil && *cfg.MaxBodySize <= 0 {
return fmt.Errorf("max_body_size must be positive, got %d", *cfg.MaxBodySize)
} Type guard
func positiveSize(p *int) bool { return p == nil || *p > 0 } Prevention
- Omit size keys you don't need instead of setting 0 to mean 'unlimited'.
- Validate generated/templated YAML values before deployment.
- Document defaults so users don't guess that 0 disables limits.
When it happens
Trigger: Calling Validate() on an http source Configuration whose ChunkSize or MaxBodySize pointer is non-nil and points to a value <= 0, e.g. YAML `chunk_size: -1` or `max_body_size: 0`.
Common situations: Typo or misunderstanding in the acquisition YAML (thinking 0 means 'unlimited'); templated configs where a variable expands to empty/0; copying a sample config with a placeholder value.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- path must start with /
- invalid HTTP status code
- basic_auth is selected, but basic_auth is not provided
- basic_auth is selected, but username is not provided
- basic_auth is selected, but password is not provided
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/7303b037536b1af2.
Report an issue: GitHub.