{"record":{"id":"7df61027da1a5ded","repo":"apache/beam","slug":"could-not-unmarshal-sharded-key-coder-from-v-expected-one","errorCode":null,"errorMessage":"could not unmarshal sharded_key coder from %v, expected one component (key) but got %d","messagePattern":"could not unmarshal sharded_key coder from (.+?), expected one component \\(key\\) but got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/coder.go","lineNumber":385,"sourceCode":"\t\t\treturn nil, err\n\t\t}\n\t\tt, err := schema.ToType(&s)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn coder.NewR(typex.New(t)), nil\n\tcase urnNullableCoder:\n\t\tif len(components) != 1 {\n\t\t\treturn nil, errors.Errorf(\"could not unmarshal nullable coder from %v, expected one component but got %d\", c, len(components))\n\t\t}\n\t\telm, err := b.Coder(components[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn coder.NewN(elm), nil\n\tcase urnShardedKeyCoder:\n\t\tif len(components) != 1 {\n\t\t\treturn nil, errors.Errorf(\"could not unmarshal sharded_key coder from %v, expected one component (key) but got %d\", c, len(components))\n\t\t}\n\t\tkeyC, err := b.Coder(components[0])\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\treturn coder.NewSK(keyC), nil\n\tcase urnIntervalWindow:\n\t\treturn coder.NewIntervalWindowCoder(), nil\n\n\t// Special handling for the global window coder so it can be treated as\n\t// a general coder. Generally window coders are not used outside of\n\t// specific contexts, but this enables improved testing.\n\t// Window types are not permitted to be fulltypes, so\n\t// we use assignably equivalent anonymous struct types.\n\tcase urnGlobalWindow:\n\t\tw, err := b.WindowCoder(id)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Errorf(\"could not unmarshal global window coder: %w\", err)","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/coder.go#L367-L403","documentation":"Error returned by makeCoder when a sharded_key coder URN has a component count other than one. A sharded-key coder wraps exactly the key coder; any other arity means the serialized coder reference is malformed or comes from an incompatible Beam version.","triggerScenarios":"Decoding a sharded_key coder whose components list is not length 1 — typically produced by SDK/runner version skew or a malformed graph.","commonSituations":"Pipelines using SDF/state+timers or runner sharded-key optimizations decoded by a harness of a different version; hand-assembled coder JSON.","solutions":["Ensure the sharded_key coder has exactly one key coder component","Align SDK versions between the job submitter and the runner/harness","Regenerate the pipeline graph with the Go SDK","Fix hand-written coder JSON to include the single key component"],"exampleFix":"// before: sharded_key coder with 2 components\n// after: {\"urn\":\"beam:coder:sharded_key:v1\",\"components\":[{\"urn\":\"beam:coder:bytes:v1\",\"components\":[]}]}","handlingStrategy":"validation","validationCode":"if ref.Urn == \"beam:coder:sharded_key:v1\" && len(ref.Components) != 1 {\n    return fmt.Errorf(\"sharded_key coder must have exactly 1 key component, got %d\", len(ref.Components))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep submitter and runner SDK versions aligned","Regenerate graphs rather than patching serialized coders","Test decode of all pipeline coders in CI"],"tags":["go","apache-beam","coder","validation"],"backgroundTag":"missing-required-argument","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"}