{"record":{"id":"a1ad32e29995b7a1","repo":"apache/beam","slug":"key-coder-for-v-is-v-want-v","errorCode":null,"errorMessage":"key coder for %v is %v, want %v","messagePattern":"key coder for (.+?) is (.+?), want (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/edge.go","lineNumber":225,"sourceCode":"\t}\n\tif !typex.IsKV(ns[0].Type()) {\n\t\treturn nil, addContext(errors.Errorf(\"input type must be KV: %v\", ns[0]), s)\n\t}\n\n\t// (1) Create CoGBK result type: KV<T,U>, .., KV<T,Z> -> CoGBK<T,U,..,Z>.\n\n\tc := ns[0].Coder.Components[0]\n\tw := inputWindow(ns)\n\tbounded := inputBounded(ns)\n\tcomp := []typex.FullType{c.T, ns[0].Type().Components()[1]}\n\n\tfor i := 1; i < len(ns); i++ {\n\t\tn := ns[i]\n\t\tif !typex.IsKV(n.Type()) {\n\t\t\treturn nil, addContext(errors.Errorf(\"input type must be KV: %v\", n), s)\n\t\t}\n\t\tif !n.Coder.Components[0].Equals(c) {\n\t\t\treturn nil, addContext(errors.Errorf(\"key coder for %v is %v, want %v\", n, n.Coder.Components[0], c), s)\n\t\t}\n\t\tif !w.Equals(n.WindowingStrategy()) {\n\t\t\treturn nil, addContext(errors.Errorf(\"mismatched CoGBK windowing strategies: %v, want %v\", n.WindowingStrategy(), w), s)\n\t\t}\n\t\tif bounded != n.Bounded() {\n\t\t\treturn nil, addContext(errors.Errorf(\"unmatched CoGBK boundedness: %v, want %v\", n.Bounded(), bounded), s)\n\t\t}\n\n\t\tcomp = append(comp, n.Type().Components()[1])\n\t}\n\n\tt := typex.NewCoGBK(comp...)\n\tout := g.NewNode(t, w, bounded)\n\n\t// (2) Add CoGBK edge\n\n\tedge := g.NewEdge(s)\n\tedge.Op = CoGBK","sourceCodeStart":207,"sourceCodeEnd":243,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/edge.go#L207-L243","documentation":"Error returned by NewCoGBK when two inputs to a CoGBK edge have different key coders: the key coder of a later input does not Equals the first input's key coder c. Even if key types agree structurally, the runner requires identical coders so keys hash/encode consistently across all joined collections.","triggerScenarios":"Inputs whose keys have the same Go type but different coders (e.g. one side uses a custom key coder variant, another the default), detected via Coder.Components[0].Equals.","commonSituations":"Applying a custom key coder on one PCollection but not another, or SDK version differences producing non-equal default coders for keys.","solutions":["Ensure all inputs derive their key coders from the same default coding of the key type","Remove or uniformly apply custom key coders across all CoGBK inputs","Explicitly set matching coders on the key side of each input"],"exampleFix":"// before\nbeam.CoGroupByKey(s, a, beam.ParDo(s, customKeyedFn, b)) // custom key coder\n// after\nbeam.CoGroupByKey(s, a, beam.ParDo(s, defaultKeyedFn, b))","handlingStrategy":"validation","validationCode":"keyCoder := inputs[0].Coder.Components[0]\nfor i, c := range inputs[1:] {\n    if !c.Coder.Components[0].Equals(keyCoder) {\n        return fmt.Errorf(\"input %d key coder mismatch\", i+1)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := beam.TryCoGroupByKey(s, a, b); err != nil {\n    return fmt.Errorf(\"CoGroupByKey key coder mismatch: %w\", err)\n}","preventionTips":["Let all key PCollections use the default coder for the key type","Apply custom key coders uniformly or not at all","Pin Beam SDK versions across pipeline components"],"tags":["go","beam","coder","cogbk"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}