{"record":{"id":"ada9f3fdd68a9b9d","repo":"apache/beam","slug":"unexpected-type-v","errorCode":null,"errorMessage":"Unexpected type: %v","messagePattern":"Unexpected type: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/coder.go","lineNumber":274,"sourceCode":"\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\n// protoEnc marshals the supplied proto.Message.\nfunc protoEnc(in T) ([]byte, error) {\n\tvar p protoreflect.ProtoMessage","sourceCodeStart":256,"sourceCodeEnd":292,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/coder.go#L256-L292","documentation":"inferCoder in sdks/go/pkg/beam/coder.go panics with \"Unexpected type: %v\" when the given FullType matches neither the atomic-kind switch nor any known composite kind, hitting the outer default. Every NewCoder, NewElementEncoder, NewElementDecoder, and coder-inference path funnels through this function, so an unclassifiable type is a fail-fast internal invariant violation.","triggerScenarios":"Passing a FullType whose typex.Kind is outside the enumerated supported kinds (e.g. a custom typex.Kind from an extension, or a hand-constructed FullType) into NewCoder / NewElementEncoder / NewElementDecoder / inferCoders.","commonSituations":"Third-party Beam extensions introducing new types; hand-built typex.FullType values in tests or wrappers; version skew where one side understands a type the other does not.","solutions":["Identify the type from the panic message and replace it with a standard Beam-representable type (primitive, struct, slice, map, KV).","If the type is legitimately new, add a case to inferCoder mapping its kind to a coder.Coder Kind.","Align Beam SDK versions across pipeline submission and worker.","Validate custom types with typex.New and confirm the kind is supported before building coders."],"exampleFix":"// before\ndefault:\n    panic(fmt.Sprintf(\"Unexpected type: %v\", t))\n// after\ncase typex.MyKind:\n    return &coder.Coder{Kind: coder.Custom, T: t}, nil\ndefault:\n    panic(fmt.Sprintf(\"Unexpected type: %v\", t))","handlingStrategy":"validation","validationCode":"if t == nil || t.Kind() == 0 {\n    return nil, fmt.Errorf(\"cannot infer coder for unknown type: %v\", t)\n}\nif _, err := beam.NewCoder(t.Type()); err != nil {\n    return nil, fmt.Errorf(\"type not coder-compatible: %w\", err)\n}","typeGuard":"func isCoderSupported(t typex.FullType) bool {\n    return t != nil && typex.IsKnownKind(t.Kind())\n}","tryCatchPattern":"func inferSafe(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":["Register custom typex kinds with the coder framework before use.","Keep SDK versions aligned between submitter and runner.","Validate all PCollection element types with NewCoder early at pipeline-construction time.","Avoid hand-constructing typex.FullType values; use typex.New on concrete reflect.Types."],"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"}