{"record":{"id":"9b882d934b4e2808","repo":"apache/beam","slug":"shardedkey-coder-must-have-only-1-component-s","errorCode":null,"errorMessage":"ShardedKey coder must have only 1 component: %s","messagePattern":"ShardedKey coder must have only 1 component: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/runners/prism/internal/coders.go","lineNumber":373,"sourceCode":"\t\treturn func(r io.Reader) {\n\t\t\tkd(r)\n\t\t\tvd(r)\n\t\t}\n\tcase urns.CoderWindowedValue:\n\t\tccids := c.GetComponentCoderIds()\n\t\tif len(ccids) != 2 {\n\t\t\tpanic(fmt.Sprintf(\"WindowedValue coder with more than 2 components: %s\", prototext.Format(c)))\n\t\t}\n\t\ted := pullDecoderNoAlloc(coders[ccids[0]], coders)\n\t\twd := pullDecoderNoAlloc(coders[ccids[1]], coders)\n\t\treturn func(r io.Reader) {\n\t\t\ted(r)\n\t\t\twd(r)\n\t\t}\n\tcase urns.CoderShardedKey:\n\t\tccids := c.GetComponentCoderIds()\n\t\tif len(ccids) != 1 {\n\t\t\tpanic(fmt.Sprintf(\"ShardedKey coder must have only 1 component: %s\", prototext.Format(c)))\n\t\t}\n\t\tkd := pullDecoderNoAlloc(coders[ccids[0]], coders)\n\t\treturn func(r io.Reader) {\n\t\t\tl, _ := coder.DecodeVarInt(r)\n\t\t\tioutilx.ReadN(r, int(l))\n\t\t\tkd(r)\n\t\t}\n\tcase urns.CoderRow:\n\t\tpanic(fmt.Sprintf(\"Runner forgot to LP this Row Coder. %v\", prototext.Format(c)))\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"unknown coder urn key: %v\", urn))\n\t}\n}\n\n// debugCoder is developer code to get the structure of a proto coder visible when\n// debugging coder errors in prism. It may sometimes be unused, so we do this to avoid\n// linting errors.\nvar _ = debugCoder","sourceCodeStart":355,"sourceCodeEnd":391,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/coders.go#L355-L391","documentation":"A ShardedKey coder must contain exactly one component coder (the key element coder). prism panics when the component list length differs, meaning the SDK sent a structurally invalid sharded-key coder.","triggerScenarios":"pullDecoderNoAlloc handles urn beam:coders:sharded_key:v1 whose GetComponentCoderIds() length != 1 — e.g. components list empty or containing multiple coder IDs.","commonSituations":"Custom GroupByKey/sharded-key coder customization gone wrong; hand-assembled coder protos in tests or tools; SDK/runner version skew changing sharded-key representation.","solutions":["Check the printed coder proto: component_coder_ids must have exactly 1 entry","Remove or fix custom coder overrides affecting sharded keys","Use stock Beam coder construction for sharded keys on the SDK side","Test with a minimal GroupByKey pipeline to isolate the source"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"if len(skCoder.GetComponentCoderIds()) != 1 { return fmt.Errorf(\"ShardedKey coder must have exactly 1 component, got %d\", len(skCoder.GetComponentCoderIds())) }","typeGuard":null,"tryCatchPattern":"defer func() { if r := recover(); r != nil { log.Errorf(\"sharded-key coder panicked: %v\", r) } }()","preventionTips":["Do not override sharded-key coders in custom code","Test custom GBK pipelines against a stock Beam release first","Keep coder proto construction inside the SDK"],"tags":["go","beam","prism","coder","panic"],"backgroundTag":"internal-invariant-violation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}