crowdsecurity/crowdsec · error
invalid value for 'max_buffer_size': %w
Error message
invalid value for 'max_buffer_size': %w
What it means
ConfigureByDSN parses the 'max_buffer_size' DSN parameter with strconv.Atoi. If the value is not a plain integer, the parse error is wrapped and returned. The parameter controls the bufio.Scanner buffer size for reading objects.
Source
Thrown at pkg/acquisition/modules/s3/config.go:241
case "log_level":
if len(value) != 1 {
return errors.New("expected zero or one value for 'log_level'")
}
lvl, err := log.ParseLevel(value[0])
if err != nil {
return fmt.Errorf("unknown level %s: %w", value[0], err)
}
s.logger.Logger.SetLevel(lvl)
case "max_buffer_size":
if len(value) != 1 {
return errors.New("expected zero or one value for 'max_buffer_size'")
}
maxBufferSize, err := strconv.Atoi(value[0])
if err != nil {
return fmt.Errorf("invalid value for 'max_buffer_size': %w", err)
}
s.logger.Debugf("Setting max buffer size to %d", maxBufferSize)
s.Config.MaxBufferSize = maxBufferSize
default:
return fmt.Errorf("unknown parameter %s", key)
}
}
}
s.Config.Labels = labels
s.Config.Mode = configuration.CAT_MODE
s.Config.UniqueId = uuid
pathParts := strings.Split(args[0], "/")
s.logger.Debugf("pathParts: %v", pathParts)
// FIXME: handle s3://bucket/View on GitHub (pinned to 909b515798)
Solutions
- Provide max_buffer_size as a plain integer number of bytes, e.g. max_buffer_size=10485760.
- Remove units or separators from the value.
- Omit the parameter to keep the default buffer size.
Example fix
// before crowdsec-s3://mybucket?max_buffer_size=10MB // after crowdsec-s3://mybucket?max_buffer_size=10485760
Defensive patterns
Strategy: validation
Validate before calling
if _, err := strconv.Atoi(bufSize); err != nil {
return fmt.Errorf("max_buffer_size must be an integer byte count, got %q", bufSize)
} Prevention
- Always emit plain byte counts, never sizes with units.
- Centralize DSN construction in one helper with parameter validation.
- Document accepted parameters where DSNs are templated.
When it happens
Trigger: DSN contains `max_buffer_size=10MB`, `max_buffer_size=abc`, or a value with spaces/units — anything strconv.Atoi cannot parse as an int.
Common situations: Users specifying units (KB/MB) or separators (underscores, commas) in the value, expecting the library to parse human-friendly sizes.
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
- unknown level %s: %w
- unknown parameter %s
- invalid DSN %s for S3 source
- unrecognized syslog message
- invalid DSN %s for S3 source, must start with s3://
AI-assisted analysis of crowdsecurity/crowdsec@909b515798 (2026-09-06).
Data as JSON: /api/errors/14be7a07ebc20d10.
Report an issue: GitHub.