{"record":{"id":"9f725f22f463fcf7","repo":"apache/beam","slug":"failed-to-marshal-shardedkey-coder-v","errorCode":null,"errorMessage":"failed to marshal ShardedKey coder %v","messagePattern":"failed to marshal ShardedKey coder (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/coder.go","lineNumber":510,"sourceCode":"\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}\n\t\tif len(comp) != 1 {\n\t\t\treturn \"\", errors.Errorf(\"ShardedKey coder requires exactly 1 component (key), got %d\", len(comp))\n\t\t}\n\t\treturn b.internBuiltInCoder(urnShardedKeyCoder, comp...), nil\n\n\tcase coder.WindowedValue:\n\t\tcomp := []string{}\n\t\tif ids, err := b.AddMulti(c.Components); err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal window coder %v\", c)\n\t\t} else {\n\t\t\tcomp = append(comp, ids...)\n\t\t}\n\t\tif id, err := b.AddWindowCoder(c.Window); err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal window coder %v\", c)\n\t\t} else {\n\t\t\tcomp = append(comp, id)\n\t\t}","sourceCodeStart":492,"sourceCodeEnd":528,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/coder.go#L492-L528","documentation":"Wraps any failure from AddMulti when marshalling the single component of a coder.ShardedKey coder. ShardedKey requires exactly one key component; component marshalling failure surfaces under this message.","triggerScenarios":"CoderBuilder.Add on a coder.ShardedKey whose key component coder fails to marshal.","commonSituations":"ShardedKey PCollections over custom key types not registered with beam.RegisterType; reshuffle pipelines with exotic key types.","solutions":["Read the wrapped error to identify the failing key component","Register the key type with beam.RegisterType before beam.Init","Use a serializable key type (primitives or registered structs)","Avoid wrapping ShardedKey in coders with unsupported components"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// Unwrap to identify the failing key component\nif err != nil && strings.Contains(err.Error(), \"ShardedKey\") {\n    log.Printf(\"ShardedKey component failure: %v\", errors.Unwrap(err))\n}","preventionTips":["Register ShardedKey custom key types before beam.Init","Use simple serializable key types","Test reshuffle paths in pipeline build tests"],"tags":["beam","go","coder","shardedkey"],"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-20T03:17:13.778Z"}