{"record":{"id":"aa7151a2683b78c7","repo":"apache/beam","slug":"bad-cogbk-v","errorCode":null,"errorMessage":"bad CoGBK: %v","messagePattern":"bad CoGBK: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/dataflow.go","lineNumber":145,"sourceCode":"\t\tinnerref, err := EncodeCoderRef(c.Components[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &CoderRef{Type: nullableType, Components: []*CoderRef{innerref}}, nil\n\n\tcase coder.Iterable:\n\t\tif len(c.Components) != 1 {\n\t\t\treturn nil, errors.Errorf(\"bad I: %v\", c)\n\t\t}\n\t\tinnerref, err := EncodeCoderRef(c.Components[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn &CoderRef{Type: streamType, Components: []*CoderRef{innerref}}, nil\n\n\tcase coder.CoGBK:\n\t\tif len(c.Components) < 2 {\n\t\t\treturn nil, errors.Errorf(\"bad CoGBK: %v\", c)\n\t\t}\n\n\t\trefs, err := EncodeCoderRefs(c.Components)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tvalue := refs[1]\n\t\tif len(c.Components) > 2 {\n\t\t\t// TODO(https://github.com/apache/beam/issues/18032): don't inject union coder for CoGBK.\n\n\t\t\tunion := &CoderRef{Type: cogbklistType, Components: refs[1:]}\n\t\t\tvalue = &CoderRef{Type: lengthPrefixType, Components: []*CoderRef{union}}\n\t\t}\n\n\t\tstream := &CoderRef{Type: streamType, Components: []*CoderRef{value}, IsStreamLike: true}\n\t\treturn &CoderRef{Type: pairType, Components: []*CoderRef{refs[0], stream}, IsPairLike: true}, nil\n","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/dataflow.go#L127-L163","documentation":"EncodeCoderRef encodes CoGBK coders as a pair of (tag, stream-of-list) refs, which requires at least two component coders (the key plus at least one value collection). A CoGBK with fewer than two components cannot be represented in the Dataflow form, so encoding fails with the offending coder in the message.","triggerScenarios":"Encoding a coder.Coder of Kind coder.CoGBK with len(c.Components) < 2 — e.g. a CoGBK coder built with only a key component, or an empty component list — during pipeline graph serialization.","commonSituations":"Custom transforms constructing CoGBK output coders without all input collections; programmatic pipeline builders that misassemble CoGBK coders; refactors that drop components from multi-input coders.","solutions":["Ensure the CoGBK coder includes the key component plus one component per input PCollection (>= 2 total).","Use beam.CoGBK / the SDK's coder construction for multi-input transforms instead of raw coder.Coder literals.","Check any custom coder provider that substitutes coders for CoGBK outputs and restore the full component list.","Re-derive the coder from the transform's inputs if it was cached from a stale pipeline version."],"exampleFix":"// before\nc := &coder.Coder{Kind: coder.CoGBK, T: t, Components: []*coder.Coder{key}}\nref, err := graphx.EncodeCoderRef(c)\n\n// after\nc := &coder.Coder{Kind: coder.CoGBK, T: t, Components: []*coder.Coder{key, value1}}\nref, err := graphx.EncodeCoderRef(c)","handlingStrategy":"validation","validationCode":"func validCoGBK(c *coder.Coder) bool {\n\treturn c != nil && c.Kind == coder.CoGBK && len(c.Components) >= 2\n}","typeGuard":"func isCoGBKWithInputs(c *coder.Coder, n int) bool { return c != nil && c.Kind == coder.CoGBK && len(c.Components) == n+1 }","tryCatchPattern":"ref, err := graphx.EncodeCoderRef(c)\nif err != nil {\n\tif strings.Contains(err.Error(), \"bad CoGBK\") {\n\t\treturn fmt.Errorf(\"CoGBK coder needs key + >=1 input components: %w\", err)\n\t}\n\treturn err\n}","preventionTips":["Build CoGBK coders via beam.CoGBK transform plumbing, never manually","When wrapping multi-input transforms, copy the full component list","Test custom multi-input transforms end-to-end before submission"],"tags":["go","beam","cogbk","coder-serialization"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-15T02:17:10.978Z"}