{"record":{"id":"8471c11164ec7f00","repo":"apache/beam","slug":"receiver-type-v-must-be-registered","errorCode":null,"errorMessage":"receiver type %v must be registered","messagePattern":"receiver type (.+?) must be registered","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/serialize.go","lineNumber":248,"sourceCode":"\t\t}}, nil\n\n\tcase u.Fn != nil:\n\t\tfn, err := encodeUserFn(u.Fn)\n\t\tif err != nil {\n\t\t\twrapped := errors.Wrap(err, \"bad userfn\")\n\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding DoFn %v\", u)\n\t\t}\n\t\treturn &v1pb.Fn{Fn: fn}, nil\n\n\tcase u.Recv != nil:\n\t\tt := reflect.TypeOf(u.Recv)\n\t\tk, ok := runtime.TypeKey(reflectx.SkipPtr(t))\n\t\tif !ok {\n\t\t\terr := errors.Errorf(\"failed to create TypeKey for receiver type %T\", u.Recv)\n\t\t\treturn nil, errors.WithContextf(err, \"encoding structural DoFn %v\", u)\n\t\t}\n\t\tif _, ok := runtime.LookupType(k); !ok {\n\t\t\terr := errors.Errorf(\"receiver type %v must be registered\", t)\n\t\t\treturn nil, errors.WithContextf(err, \"encoding structural DoFn %v\", u)\n\t\t}\n\t\ttyp, err := encodeType(t)\n\t\tif err != nil {\n\t\t\twrapped := errors.Wrapf(err, \"failed to encode receiver type %T\", u.Recv)\n\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding structural DoFn %v\", u)\n\t\t}\n\n\t\tdata, err := jsonx.Marshal(u.Recv)\n\t\tif err != nil {\n\t\t\twrapped := errors.Wrapf(err, \"failed to marshal receiver %v\", u.Recv)\n\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding structural DoFn %v\", u)\n\t\t}\n\t\treturn &v1pb.Fn{Type: typ, Opt: string(data)}, nil\n\n\tdefault:\n\t\treturn nil, errors.Errorf(\"failed to encode DoFn %v, missing fn\", u)\n\t}","sourceCodeStart":230,"sourceCodeEnd":266,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/serialize.go#L230-L266","documentation":"Thrown by encodeFn in Beam Go's graphx serializer when encoding a structural DoFn whose receiver type has no runtime.TypeKey or is not present in the runtime type registry (LookupType fails). Beam requires all serialized types to be pre-registered so the pipeline can be decoded on a worker; an unregistered receiver type would produce a graph the remote process cannot reconstruct.","triggerScenarios":"Calling EncodeMultiEdge on a transform whose DoFn is a structural/custom fn whose receiver type was never registered via runtime.RegisterType (or the beam package's init-time registration).","commonSituations":"Using a locally-defined or anonymous struct DoFn in a custom transform; registering types in a package the worker binary does not import; renaming/moving a type so registry init no longer runs.","solutions":["Register the receiver type at package init with runtime.RegisterType(reflect.TypeOf(MyFn{})) (or call beam.RegisterFunction/registerDoFn helpers).","Ensure the package containing the registration is imported by both the driver and the worker binary.","Verify with runtime.TypeKey(reflectx.SkipPtr(reflect.TypeOf(fn))) and runtime.LookupType that the type resolves before building the pipeline.","If the DoFn is genuinely dynamic/anonymous, switch to a named registered type or an emulated/serialized DoFn form."],"exampleFix":"// before\nfunc init() { /* no registration */ }\ntype myFn struct{}\n\n// after\ntype myFn struct{}\nfunc init() { runtime.RegisterType(reflect.TypeOf(myFn{})) }","handlingStrategy":"validation","validationCode":"k, ok := runtime.TypeKey(reflectx.SkipPtr(reflect.TypeOf(myFn{})))\nif !ok || func() bool { _, ok := runtime.LookupType(k); return !ok }() {\n    runtime.RegisterType(reflect.TypeOf(myFn{}))\n}","typeGuard":"func typeRegistered(t reflect.Type) bool {\n    k, ok := runtime.TypeKey(reflectx.SkipPtr(t))\n    if !ok { return false }\n    _, found := runtime.LookupType(k)\n    return found\n}","tryCatchPattern":null,"preventionTips":["Register every custom DoFn type in an init() function.","Blank-import registration packages from the worker main.","Write a unit test asserting typeRegistered(reflect.TypeOf(each DoFn))."],"tags":["go","serialization","type-registry","apache-beam"],"backgroundTag":"type-not-registered","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}