{"record":{"id":"184980426a154bdb","repo":"apache/beam","slug":"failed-to-marshal-cogbk-coder-v","errorCode":null,"errorMessage":"failed to marshal CoGBK coder %v","messagePattern":"failed to marshal CoGBK coder (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/coder.go","lineNumber":493,"sourceCode":"\n\tcase coder.KV:\n\t\tcomp, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal KV coder %v\", c)\n\t\t}\n\t\treturn b.internBuiltInCoder(urnKVCoder, comp...), nil\n\n\tcase coder.Nullable:\n\t\tcomp, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal Nullable coder %v\", c)\n\t\t}\n\t\treturn b.internBuiltInCoder(urnNullableCoder, comp...), nil\n\n\tcase coder.CoGBK:\n\t\tcomp, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal CoGBK coder %v\", c)\n\t\t}\n\t\tvalue := comp[1]\n\t\tif len(comp) > 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 := b.internBuiltInCoder(urnCoGBKList, comp[1:]...)\n\t\t\tvalue = b.internBuiltInCoder(urnLengthPrefixCoder, union)\n\t\t}\n\n\t\t// SDKs always provide iterableCoder to runners, but can receive StateBackedIterables in return.\n\t\tstream := b.internBuiltInCoder(urnIterableCoder, value)\n\t\treturn b.internBuiltInCoder(urnKVCoder, comp[0], stream), nil\n\n\tcase coder.ShardedKey:\n\t\tcomp, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal ShardedKey coder %v\", c)\n\t\t}","sourceCodeStart":475,"sourceCodeEnd":511,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/coder.go#L475-L511","documentation":"Wrap returned by Add when marshaling a coder.CoGBK: AddMulti failed on the CoGBK's component coders. The wrapped inner error carries the actual cause (a component coder that could not be interned); the message identifies the CoGBK coder being serialized for diagnosis.","triggerScenarios":"CoderBuilder.Add on a coder.CoGBK where one of the key/value component coders fails to marshal.","commonSituations":"CoGBK PCollections with unregistered custom key or value types; cross-language expansions producing components the Go marshaller cannot encode.","solutions":["Inspect the wrapped error to find the failing component coder","Register custom key/value types with beam.RegisterType before beam.Init","Replace unencodable component types with serializable ones","Check the expansion output coders if this occurs after a cross-language transform"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Unwrap to find the failing CoGBK component\nif err != nil && strings.Contains(err.Error(), \"CoGBK\") {\n    log.Printf(\"CoGBK component failure: %v\", errors.Unwrap(err))\n}","preventionTips":["Register all CoGBK key/value custom types before beam.Init","Check coders after cross-language expansions","Add pipeline-build tests covering CoGBK transforms"],"tags":["beam","go","coder","cogbk"],"backgroundTag":"json-marshal-failed","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"}