{"record":{"id":"77848e5971025003","repo":"apache/beam","slug":"unexpected-composite-type-v-fulltype","errorCode":null,"errorMessage":"Unexpected composite type: %v","messagePattern":"Unexpected composite type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/typex/fulltype.go","lineNumber":160,"sourceCode":"\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}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Invalid underlying type: %v\", t))\n\t}\n}\n\n// NOTE(herohde) 1/26/2018: we allow nested KV types and coders to support the\n// CoGBK translation (using KV<K,KV<int,[]byte>> to encode keyed raw union values)\n// and potentially other uses. We do not have a reasonable way to emit nested KV\n// values, so user functions are still limited to non-nested KVs. Universally-typed\n// KV-values might be simple to allow, for example.\n\nfunc isAnyNonKVComposite(list []FullType) bool {\n\tfor _, t := range list {\n\t\tif t.Class() == Composite && t.Type() != KVType {\n\t\t\treturn true\n\t\t}\n\t}","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/typex/fulltype.go#L142-L178","documentation":"In typex.New's Composite branch, the switch over the type class only recognizes KV, CoGBK, WindowedValue, Timers and ShardedKey. Any other composite type class falls into the default case and panics with 'Unexpected composite type'. This guards against new or unknown composite classes reaching the tree builder without validation logic.","triggerScenarios":"Calling typex.New with a Composite whose class is not one of KVType, CoGBKType, WindowedValueType, TimersType or ShardedKeyType — e.g. a custom or future typex class added upstream but not handled here. Reached via New's public callers (Prefix, CoGroupByKey, CombinePerKey, CombineGlobally, Flatten, GroupByKey).","commonSituations":"Using a Beam version where a new composite type class was introduced elsewhere but the fulltype validation wasn't updated; constructing composite types from raw class values programmatically instead of via the typed helpers.","solutions":["Use one of the supported composite classes (KV, CoGBK, WindowedValue, Timers, ShardedKey) when calling typex.New.","Upgrade or align the Beam SDK versions in your module graph so type classes and validation agree (go mod tidy / go get -u sdks/go).","If you added a custom composite class, add a case for it in New's switch in fulltype.go."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"var supportedComposites = map[typex.Type]bool{\n    typex.KVType: true, typex.CoGBKType: true, typex.WindowedValueType: true,\n    typex.TimersType: true, typex.ShardedKeyType: true,\n}","typeGuard":null,"tryCatchPattern":"func safeNew(t typex.Type, cs ...typex.FullType) (ft typex.FullType, err error) {\n    defer func() {\n        if r := recover(); r != nil { err = fmt.Errorf(\"typex.New: %v\", r) }\n    }()\n    return typex.New(t, cs...), nil\n}","preventionTips":["Restrict composite construction to the known supported classes.","Keep Beam SDK versions consistent across modules.","Re-check type construction code after SDK upgrades."],"tags":["go","apache-beam","typex","panic","unknown-type"],"backgroundTag":"invalid-enum-value","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"}