apache/beam · error
bundle size must be greater than 0
Error message
bundle size must be greater than 0
What it means
WithReadBundleSize is a ReadOption for the Beam MongoDB connector that sets the target byte size of each read bundle. It rejects non-positive values because a zero or negative bundle size makes splitting the _id range meaningless. The error is returned when the option function is applied to ReadOption.
Source
Thrown at sdks/go/pkg/beam/io/mongodbio/read_option.go:54
return func(o *ReadOption) error {
o.BucketAuto = bucketAuto
return nil
}
}
// WithReadFilter configures the ReadOption to use the provided filter.
func WithReadFilter(filter bson.M) ReadOptionFn {
return func(o *ReadOption) error {
o.Filter = filter
return nil
}
}
// WithReadBundleSize configures the ReadOption to use the provided bundle size in bytes.
func WithReadBundleSize(bundleSize int64) ReadOptionFn {
return func(o *ReadOption) error {
if bundleSize <= 0 {
return errors.New("bundle size must be greater than 0")
}
o.BundleSize = bundleSize
return nil
}
}
View on GitHub (pinned to 12126d8942)
Solutions
- Pass a strictly positive byte size, e.g. mongodbio.WithReadBundleSize(64 * 1024 * 1024).
- If the value comes from config or flags, validate it is > 0 before constructing the ReadOptions and provide a sane default (e.g. 64MB).
- Check that the parsed config value did not silently become 0 due to a parse failure.
Example fix
// before
opts = append(opts, mongodbio.WithReadBundleSize(bundleSize)) // bundleSize == 0 from missing flag
// after
if bundleSize <= 0 {
bundleSize = 64 * 1024 * 1024
}
opts = append(opts, mongodbio.WithReadBundleSize(bundleSize)) Defensive patterns
Strategy: validation
Validate before calling
if bundleSize <= 0 {
return fmt.Errorf("bundleSize must be > 0, got %d", bundleSize)
}
opts = append(opts, mongodbio.WithReadBundleSize(bundleSize)) Try / catch
if err := mongodbio.Read(scope, db, collection, opts...); err != nil {
return fmt.Errorf("mongodbio read options invalid: %w", err)
} Prevention
- Give bundle-size flags/env vars a positive default (e.g. 64MB).
- Validate all numeric options at pipeline-argument parsing time.
- Distinguish clearly between bundle size and batch size config fields to avoid mixups.
When it happens
Trigger: Passing mongodbio.WithReadBundleSize(0) or a negative value into the options slice of mongodbio.Read (or ReadList), which applies each option and fails on the first invalid one.
Common situations: Bundle size read from config/CLI flags with a zero default that was never set; int64 conversion of a value that failed parsing to 0; copy-paste where the user meant to set batch size, not bundle size.
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
- batch size must be greater than 0
- fraction must be between 0 and 1
- fetch size must be greater than 0
- start sequence number must be greater than 0
- end sequence number must be greater than 0
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/85692d7310b12b25.
Report an issue: GitHub.