{"record":{"id":"0fd58162bc53449c","repo":"apache/beam","slug":"invalid-number-of-components-for-cogbk-v","errorCode":null,"errorMessage":"Invalid number of components for CoGBK: %v","messagePattern":"Invalid number of components for CoGBK: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/typex/fulltype.go","lineNumber":143,"sourceCode":"\t\tcase KVType:\n\t\t\tif len(components) != 2 {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid number of components for KV: %v, %v\", t, components))\n\t\t\t}\n\t\t\tif isAnyNonKVAndNonWindowedComposite(components) {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid to nest composite composites inside KV: %v, %v\", t, components))\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tcase WindowedValueType:\n\t\t\tif len(components) != 1 {\n\t\t\t\tpanic(\"Invalid number of components for WindowedValue\")\n\t\t\t}\n\t\t\tif components[0].Type() == WindowedValueType {\n\t\t\t\tpanic(\"Invalid to nest WindowedValue\")\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tcase CoGBKType:\n\t\t\tif len(components) < 2 {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid number of components for CoGBK: %v\", t))\n\t\t\t}\n\t\t\tif isAnyNonKVComposite(components) {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid to nest composites inside CoGBK: %v\", t))\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tcase TimersType:\n\t\t\treturn &tree{class, t, components}\n\t\tcase ShardedKeyType:\n\t\t\tif len(components) != 1 {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid number of components for ShardedKey: %v, %v\", t, components))\n\t\t\t}\n\t\t\tif components[0].Class() == Composite {\n\t\t\t\tpanic(fmt.Sprintf(\"Invalid to nest composite inside ShardedKey: %v, %v\", t, components))\n\t\t\t}\n\t\t\treturn &tree{class, t, components}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"Unexpected composite type: %v\", t))\n\t\t}","sourceCodeStart":125,"sourceCodeEnd":161,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/typex/fulltype.go#L125-L161","documentation":"FullType.New requires at least two components for a CoGBK composite (one key plus at least one value collection); fewer panics. CoGBK represents a keyed multi-input grouping type, so a component count below 2 cannot encode a grouping.","triggerScenarios":"Calling typex.New (or CoGroupByKey / related graph helpers) with CoGBKType and a components slice of length 0 or 1, e.g. from a malformed transform input list.","commonSituations":"Custom graph builders passing an incomplete PCollection list to CoGroupByKey-shaped types; codegen emitting single-input CoGBK constructs instead of GBK.","solutions":["Provide at least a key and one value component when constructing a CoGBK type.","For single-input grouping, use GroupByKey / GBKType instead of CoGBK.","Validate the number of input PCollections before building the CoGBK type."],"exampleFix":"// before\ntypex.New(typex.CoGBKType, keyFT) // 1 component: panics\n// after\ntypex.New(typex.CoGBKType, keyFT, valFT1, valFT2)","handlingStrategy":"validation","validationCode":"if t == typex.CoGBKType && len(components) < 2 {\n\treturn fmt.Errorf(\"CoGBK requires at least 2 components, got %d\", len(components))\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use beam.CoGroupByKey only with two or more input PCollections.","For single-input grouping use GroupByKey instead of a CoGBK type.","Validate input PCollection counts before building graph nodes."],"tags":["go","beam","typex","cogbk","panic"],"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"}