{"record":{"id":"7fd1f67ada2df5fe","repo":"apache/beam","slug":"groupintobatches-w","errorCode":null,"errorMessage":"GroupIntoBatches: %w","messagePattern":"GroupIntoBatches: %w","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/transforms/batch/batch.go","lineNumber":580,"sourceCode":"\tRegisterShardedKeyType[string]()\n\tRegisterShardedKeyType[int]()\n\tRegisterShardedKeyType[int64]()\n}\n\n// GroupIntoBatches groups the values of the input PCollection<KV<K, V>>\n// into batches of up to params.BatchSize elements (or\n// params.BatchSizeBytes bytes) per key and emits them as\n// PCollection<KV<K, []V>>.\n//\n// The input must be KV-typed. The key coder must be deterministic;\n// non-deterministic key coders would corrupt state keying. Panics at\n// pipeline build time on invalid params, non-KV input, zero limits, or\n// a non-deterministic key coder.\nfunc GroupIntoBatches(s beam.Scope, params Params, col beam.PCollection) beam.PCollection {\n\ts = s.Scope(\"batch.GroupIntoBatches\")\n\n\tif err := params.validate(); err != nil {\n\t\tpanic(fmt.Errorf(\"GroupIntoBatches: %w\", err))\n\t}\n\tif !typex.IsKV(col.Type()) {\n\t\tpanic(fmt.Errorf(\n\t\t\t\"GroupIntoBatches: input PCollection must be KV-typed; got %v\", col.Type()))\n\t}\n\n\tkeyFT := col.Type().Components()[0]\n\tvalFT := col.Type().Components()[1]\n\n\tif !beam.NewCoder(keyFT).IsDeterministic() {\n\t\tpanic(fmt.Errorf(\n\t\t\t\"GroupIntoBatches: key coder for type %v is not deterministic. \"+\n\t\t\t\t\"Register a deterministic custom coder with \"+\n\t\t\t\t\"coder.RegisterDeterministicCoder, or use a deterministic key \"+\n\t\t\t\t\"type (string, []byte, bool, integer, float)\", keyFT.Type()))\n\t}\n\n\tsizerKind := sizerNone","sourceCodeStart":562,"sourceCodeEnd":598,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/transforms/batch/batch.go#L562-L598","documentation":"GroupIntoBatches panics when params.validate() reports any invalid Params field (negative sizes, no size/byte limit, negative buffering duration). The underlying validate error is wrapped with %w and raised as a panic at pipeline build time. The panic message embeds the specific field problem.","triggerScenarios":"Calling GroupIntoBatches(s, params, col) with a Params whose BatchSizeBytes < 0, MaxBufferingDuration < 0, or with both BatchSize == 0 and BatchSizeBytes == 0.","commonSituations":"Building Params from user-supplied flags or YAML where limits are unset (zero) or negative; upgrading Beam and relying on previously-permitted defaults.","solutions":["Read the wrapped cause in the panic text to see which field failed","Set BatchSize > 0 or BatchSizeBytes > 0 (at least one limit required)","Ensure no limit/buffer fields are negative","Validate Params before entering pipeline construction"],"exampleFix":"// before\nparams := batch.Params{} // no limits set\n// after\nparams := batch.Params{BatchSize: 500}","handlingStrategy":"validation","validationCode":"if params.BatchSize <= 0 && params.BatchSizeBytes <= 0 {\n    return errors.New(\"set BatchSize or BatchSizeBytes > 0\")\n}\nif err := params.validate(); err != nil { return err }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never pass zero-valued Params{}","Validate before building pipelines","Centralize Params construction in one helper"],"tags":["go","apache-beam","panic","invalid-params"],"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-14T11:17:12.474Z"}