{"record":{"id":"965e51966379d50a","repo":"apache/beam","slug":"invalid-to-nest-composite-composites-inside-kv-v-v","errorCode":null,"errorMessage":"Invalid to nest composite composites inside KV: %v, %v","messagePattern":"Invalid to nest composite composites inside KV: (.+?), (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/typex/fulltype.go","lineNumber":130,"sourceCode":"\t\tcase reflect.Slice:\n\t\t\tif len(components) == 0 {\n\t\t\t\t// For elements without sub components, we just create with the type, this handles vanilla slices.\n\t\t\t\t// We include the child type as a component for convenience.\n\t\t\t\treturn &tree{class, t, []FullType{New(t.Elem())}}\n\t\t\t}\n\t\t\t// For elements which themselves have components, we need to go deeper.\n\t\t\treturn &tree{class, t, []FullType{New(t.Elem(), components[0].Components()...)}}\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"Unexpected aggregate type: %v\", t))\n\t\t}\n\tcase Composite:\n\t\tswitch t {\n\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}","sourceCodeStart":112,"sourceCodeEnd":148,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/typex/fulltype.go#L112-L148","documentation":"FullType.New rejects KV composites whose components include composite types that are neither KV nor WindowedValue. Nesting arbitrary composites inside a KV would break the SDK's encoding and grouping assumptions, so it panics instead.","triggerScenarios":"Calling typex.New with KVType where at least one of the two components is itself a composite class (e.g. CoGBK or nested composite) rather than a concrete/Container/KV/WindowedValue type.","commonSituations":"Building deeply nested custom composite types for pipeline data; migrating pipelines that used nested composite representations unsupported by the Go SDK.","solutions":["Flatten nested composites: use KV of concrete or container types only.","If grouping multiple values, use CoGBK (KV<K, Iter<V>>) shapes rather than nesting composites.","Wrap the value in WindowedValue if windowing metadata must be nested."],"exampleFix":"// before\ntypex.New(typex.KVType, coGBKComponent, valueFT) // nested composite: panics\n// after\ntypex.New(typex.KVType, keyFT, valueFT)","handlingStrategy":"validation","validationCode":"for _, c := range components {\n\tif c.Type() == typex.Composite && c.Type() != typex.KVType && c.Type() != typex.WindowedValueType {\n\t\treturn errors.New(\"cannot nest composites inside KV\")\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep KV values as concrete, container, KV, or WindowedValue types only.","Model multi-collection grouping with CoGBK rather than nested composites."],"tags":["go","beam","typex","kv","nesting","panic"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}