{"record":{"id":"75133a6954b5eee1","repo":"apache/beam","slug":"groupintobatches-key-coder-for-type-v-is-not-deterministic","errorCode":null,"errorMessage":"GroupIntoBatches: key coder for type %v is not deterministic. Register a deterministic custom coder with coder.RegisterDeterministicCoder, or use a deterministic key type (string, []byte, bool, integer, float)","messagePattern":"GroupIntoBatches: key coder for type (.+?) is not deterministic\\. Register a deterministic custom coder with coder\\.RegisterDeterministicCoder, or use a deterministic key type \\(string, \\[\\]byte, bool, integer, float\\)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/transforms/batch/batch.go","lineNumber":591,"sourceCode":"// 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\n\tif params.BatchSizeBytes > 0 {\n\t\tif !isBuiltinSizeable(valFT.Type()) {\n\t\t\tpanic(fmt.Errorf(\n\t\t\t\t\"GroupIntoBatches: BatchSizeBytes > 0 requires value type %v \"+\n\t\t\t\t\t\"to be a built-in primitive ([]byte, string, numeric, bool)\",\n\t\t\t\tvalFT.Type()))\n\t\t}\n\t\tsizerKind = sizerPrimitive\n\t}\n\n\tallowedLatenessMs := int64(col.WindowingStrategy().AllowedLateness)","sourceCodeStart":573,"sourceCodeEnd":609,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/transforms/batch/batch.go#L573-L609","documentation":"GroupIntoBatches shuffles and buffers by key, which requires a deterministic key coder so encoded keys can be compared/decoded consistently across workers. The default coder for the key type is non-deterministic, so the transform panics at build time. Register a deterministic coder or switch key types.","triggerScenarios":"Calling GroupIntoBatches with a key type where beam.NewCoder(keyFT).IsDeterministic() is false — e.g. struct/map keys without a registered deterministic coder.","commonSituations":"Using custom struct keys in Go Beam, where the default coder is not deterministic; forgetting coder.RegisterDeterministicCoder in init().","solutions":["Implement and register a deterministic coder: coder.RegisterDeterministicCoder(MyKey{}) in init()","Switch keys to inherently deterministic types (string, []byte, bool, numerics, float)","Serialize the key to bytes/string yourself before grouping","Verify with beam.NewCoder(keyType).IsDeterministic() in a test"],"exampleFix":"// before\ntype Key struct{ A, B string } // non-deterministic default coder\n// after\nfunc init() {\n    coder.RegisterDeterministicCoder(Key{})\n}\ntype Key struct{ A, B string }","handlingStrategy":"validation","validationCode":"if !beam.NewCoder(reflect.TypeOf(Key{})).IsDeterministic() {\n    coder.RegisterDeterministicCoder(Key{})\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Register deterministic coders in init()","Prefer primitive key types","Add a build-time coder-determinism test"],"tags":["go","apache-beam","coder","determinism"],"backgroundTag":"unsupported-operation","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"}