{"record":{"id":"2e8b0f607e144846","repo":"apache/beam","slug":"failed-to-make-gbk-union-coder","errorCode":null,"errorMessage":"failed to make GBK Union coder.","messagePattern":"failed to make GBK Union coder\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/cogbk.go","lineNumber":98,"sourceCode":"\tkvCoder, err := makeUnionCoder()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to make KV Union coder.\")\n\t}\n\treturn coder.NewKV([]*coder.Coder{key, kvCoder}), nil\n}\n\n// MakeGBKUnionCoder returns CoGBK<K,KV<int,[]byte>> for a given CoGBK.\nfunc MakeGBKUnionCoder(gbk *graph.MultiEdge) (*coder.Coder, error) {\n\tif gbk.Op != graph.CoGBK {\n\t\terr := errors.Errorf(\"expected CoGBK, got %v\", gbk)\n\t\treturn nil, errors.WithContext(err, \"failed to make GBK Union coder\")\n\t}\n\n\tfrom := gbk.Input[0].From\n\tkey := from.Coder.Components[0]\n\tkvCoder, err := makeUnionCoder()\n\tif err != nil {\n\t\treturn nil, errors.Wrapf(err, \"failed to make GBK Union coder.\")\n\t}\n\treturn coder.NewCoGBK([]*coder.Coder{key, kvCoder}), nil\n}\n\n// makeUnionCoder returns a coder for the raw union value, KV<int,[]byte>. It uses\n// varintz instead of the built-in varint to avoid the implicit length-prefixing\n// of varint otherwise introduced by Dataflow.\nfunc makeUnionCoder() (*coder.Coder, error) {\n\tc, err := coderx.NewVarIntZ(reflectx.Int)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\treturn coder.NewKV([]*coder.Coder{\n\t\t{Kind: coder.Custom, T: typex.New(reflectx.Int), Custom: c},\n\t\tcoder.NewBytes(),\n\t}), nil\n}\n","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/cogbk.go#L80-L116","documentation":"Produced by MakeGBKUnionCoder when its internal makeUnionCoder() call fails while building the KV<int,[]byte> union value coder. The SDK wraps the cause with 'failed to make GBK Union coder.', indicating the CoGBK output coder for reshuffle could not be constructed.","triggerScenarios":"Calling MakeGBKUnionCoder on a valid CoGBK MultiEdge while makeUnionCoder() errors during construction of its component coders (varintz int + raw bytes).","commonSituations":"Internal construction failure in reshuffle coder assembly; broken local builds/patches of graphx; exercised primarily by tests (TestMakeGBKUnionCoder_bad) and expandCoGBK in production code.","solutions":["Unwrap the error to read the underlying makeUnionCoder cause.","Rebuild/upgrade to an unmodified stable Apache Beam release.","Check that default component coders (varintz, bytes) are intact and not shadowed by custom code.","Reproduce minimally and report to Apache Beam if it persists.","Avoid custom reshuffle paths that force GBK union coder construction until fixed."],"exampleFix":"// before\nc, err := graphx.MakeGBKUnionCoder(gbkEdge) // err: failed to make GBK Union coder.\n// after\nif err != nil {\n    return fmt.Errorf(\"gbk union coder: %w\", err) // surface wrapped cause\n}","handlingStrategy":"try-catch","validationCode":"if gbk == nil || len(gbk.Input) == 0 || gbk.Input[0].From == nil || gbk.Input[0].From.Coder == nil {\n    return errors.New(\"CoGBK edge lacks input coder needed for GBK union coder\")\n}","typeGuard":"func hasInputCoder(e *graph.MultiEdge) bool {\n    return e != nil && len(e.Input) > 0 && e.Input[0].From != nil && e.Input[0].From.Coder != nil\n}","tryCatchPattern":"kvCoder, err := makeUnionCoder()\nif err != nil {\n    return nil, fmt.Errorf(\"GBK union coder: %w\", err)\n}","preventionTips":["Avoid local patches to graphx union-coder construction.","Ensure prerequisite component coders are constructible in your build.","Escalate reproducible internal failures to the Beam project."],"tags":["go","apache-beam","cogbk","coder-construction"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}