{"record":{"id":"85692d7310b12b25","repo":"apache/beam","slug":"bundle-size-must-be-greater-than-0","errorCode":null,"errorMessage":"bundle size must be greater than 0","messagePattern":"bundle size must be greater than 0","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/io/mongodbio/read_option.go","lineNumber":54,"sourceCode":"\treturn func(o *ReadOption) error {\n\t\to.BucketAuto = bucketAuto\n\t\treturn nil\n\t}\n}\n\n// WithReadFilter configures the ReadOption to use the provided filter.\nfunc WithReadFilter(filter bson.M) ReadOptionFn {\n\treturn func(o *ReadOption) error {\n\t\to.Filter = filter\n\t\treturn nil\n\t}\n}\n\n// WithReadBundleSize configures the ReadOption to use the provided bundle size in bytes.\nfunc WithReadBundleSize(bundleSize int64) ReadOptionFn {\n\treturn func(o *ReadOption) error {\n\t\tif bundleSize <= 0 {\n\t\t\treturn errors.New(\"bundle size must be greater than 0\")\n\t\t}\n\n\t\to.BundleSize = bundleSize\n\t\treturn nil\n\t}\n}\n","sourceCodeStart":36,"sourceCodeEnd":61,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/mongodbio/read_option.go#L36-L61","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nopts = append(opts, mongodbio.WithReadBundleSize(bundleSize)) // bundleSize == 0 from missing flag\n// after\nif bundleSize <= 0 {\n    bundleSize = 64 * 1024 * 1024\n}\nopts = append(opts, mongodbio.WithReadBundleSize(bundleSize))","handlingStrategy":"validation","validationCode":"if bundleSize <= 0 {\n    return fmt.Errorf(\"bundleSize must be > 0, got %d\", bundleSize)\n}\nopts = append(opts, mongodbio.WithReadBundleSize(bundleSize))","typeGuard":null,"tryCatchPattern":"if err := mongodbio.Read(scope, db, collection, opts...); err != nil {\n    return fmt.Errorf(\"mongodbio read options invalid: %w\", err)\n}","preventionTips":["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."],"tags":["go","apache-beam","mongodb","config-validation"],"backgroundTag":"invalid-config-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}