{"record":{"id":"be592d855a3be0f5","repo":"apache/beam","slug":"unexpected-composite-type-v","errorCode":null,"errorMessage":"Unexpected composite type: %v","messagePattern":"Unexpected composite type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/coder.go","lineNumber":271,"sourceCode":"\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\n\t\tswitch t.Type() {\n\t\tcase typex.KVType:\n\t\t\treturn &coder.Coder{Kind: coder.KV, T: t, Components: c}, nil\n\t\tcase typex.CoGBKType:\n\t\t\treturn &coder.Coder{Kind: coder.CoGBK, T: t, Components: c}, nil\n\t\tcase typex.WindowedValueType:\n\t\t\t// TODO(herohde) 4/15/2018: do we ever infer W types now that PCollections\n\t\t\t// are non-windowed? We either need to know the windowing strategy or\n\t\t\t// we should remove this case.\n\t\t\treturn &coder.Coder{Kind: coder.WindowedValue, T: t, Components: c, Window: coder.NewGlobalWindow()}, nil\n\t\tcase typex.ShardedKeyType:\n\t\t\treturn &coder.Coder{Kind: coder.ShardedKey, T: t, Components: c}, nil\n\n\t\tdefault:\n\t\t\tpanic(fmt.Sprintf(\"Unexpected composite type: %v\", t))\n\t\t}\n\tdefault:\n\t\tpanic(fmt.Sprintf(\"Unexpected type: %v\", t))\n\t}\n}\n\nfunc inferCoders(list []FullType) ([]*coder.Coder, error) {\n\tvar ret []*coder.Coder\n\tfor _, t := range list {\n\t\tc, err := inferCoder(t)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tret = append(ret, c)\n\t}\n\treturn ret, nil\n}\n","sourceCodeStart":253,"sourceCodeEnd":289,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/coder.go#L253-L289","documentation":"inferCoder in sdks/go/pkg/beam/coder.go panics with \"Unexpected composite type: %v\" when it encounters a composite (multi-component) FullType whose kind is not one of the supported composite kinds (KV, CoGBK, WindowedValue, ShardedKey, etc.). This is a defensive programmer-error panic: the Beam type system should have rejected the type earlier, so reaching the default branch means an unhandled typex kind reached coder inference. It aborts pipeline construction immediately.","triggerScenarios":"Calling NewElementEncoder, NewElementDecoder, NewCoder, inferCoders, or a transform like TryCombinePerKey with a composite FullType kind not covered by inferCoder's switch — e.g. a custom typex kind registered by an extension, or a kind added in a newer Beam release while running an older coder.go.","commonSituations":"Upgrading Beam so pipeline data flows through a composite type the installed coder.go does not handle; custom DoFn/PCollection element types using exotic typex kinds; SDK/worker version skew.","solutions":["Identify the kind from the panic message; if it is a custom or unsupported kind, change the PCollection element type to a supported one (KV, struct, slice, etc.).","Align the Beam SDK version so inferCoder knows the composite kind (it was likely added in a newer release).","If you maintain a fork, add a case to inferCoder mapping the missing kind to the correct coder.Coder Kind.","Isolate which transform introduced the type and adjust its type hints."],"exampleFix":"// before\ndefault:\n    panic(fmt.Sprintf(\"Unexpected composite type: %v\", t))\n// after\ncase typex.MyCustomKind:\n    return &coder.Coder{Kind: coder.MyCustomKind, T: t, Components: c}, nil\ndefault:\n    panic(fmt.Sprintf(\"Unexpected composite type: %v\", t))","handlingStrategy":"validation","validationCode":"if t == nil || !isSupportedKind(t.Kind()) {\n    return nil, fmt.Errorf(\"unsupported composite type for coder inference: %v\", t)\n}\nc, err := beam.NewCoder(t.Type())\nif err != nil {\n    return nil, err\n}","typeGuard":"func isSupportedKind(k typex.Kind) bool {\n    switch k {\n    case typex.KVKind, typex.CoGBKKind, typex.WindowedValueKind, typex.ShardedKeyKind:\n        return true\n    }\n    return false\n}","tryCatchPattern":"func inferCoderSafe(t typex.FullType) (c *coder.Coder, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"coder inference panicked for type %v: %v\", t, r)\n        }\n    }()\n    return beam.NewCoder(t.Type())\n}","preventionTips":["Only use typex kinds enumerated by the installed Beam release in element types.","Keep the Beam SDK version identical across pipeline construction and workers.","Add a unit test calling beam.NewCoder for every element type your pipeline uses.","Pin Beam dependencies so upgrades cannot introduce unknown composite kinds silently."],"tags":["go","apache-beam","coder","panic","type-inference"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}