{"record":{"id":"2626647ca42922c2","repo":"apache/beam","slug":"type-v-is-not-registered-ensure-that-beam-registertype-v-is","errorCode":null,"errorMessage":"type %v is not registered. Ensure that beam.RegisterType(%v) is called before beam.Init().","messagePattern":"type (.+?) is not registered\\. Ensure that beam\\.RegisterType\\((.+?)\\) is called before beam\\.Init\\(\\)\\.","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"critical","filePath":"sdks/go/pkg/beam/io/bigqueryio/bigquery.go","lineNumber":242,"sourceCode":"\n\tcheckTypeRegistered(t)\n\n\tschema, err := bigquery.InferSchema(reflect.Zero(t).Interface())\n\tif err != nil {\n\t\tpanic(errors.Wrapf(err, \"invalid schema type: %v\", t))\n\t}\n\treturn schema\n}\n\nfunc checkTypeRegistered(t reflect.Type) {\n\tt = reflectx.SkipPtr(t)\n\tkey, ok := runtime.TypeKey(t)\n\tif !ok {\n\t\tpanic(fmt.Sprintf(\"type %v must be a named type (not anonymous) for registration\", t))\n\t}\n\n\tif _, registered := runtime.LookupType(key); !registered {\n\t\tpanic(fmt.Sprintf(\"type %v is not registered. Ensure that beam.RegisterType(%v) \"+\n\t\t\t\"is called before beam.Init().\", t, t))\n\t}\n}\n\nfunc mustParseTable(table string) QualifiedTableName {\n\tqn, err := NewQualifiedTableName(table)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\treturn qn\n}\n\n// TODO(herohde) 7/14/2017: allow WriteDispositions. The default\n// is not quite what the Dataflow examples do.\n\n// writeOptions represents additional options for executing a write\ntype writeOptions struct {\n\t// CreateDisposition specifies the circumstances under which destination table will be created","sourceCodeStart":224,"sourceCodeEnd":260,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/io/bigqueryio/bigquery.go#L224-L260","documentation":"checkTypeRegistered panics when the named struct type used with bigqueryio has not been registered with beam.RegisterType before beam.Init(). Beam's runtime needs a global type registry so worker binaries can decode/encode elements across processes; an unregistered type would fail during pipeline serialization/execution.","triggerScenarios":"Calling bigqueryio.Read or bigqueryio.Write with a named struct type T for which beam.RegisterType(reflect.TypeOf(T{})) was never called, then running with a distributed runner that requires registration.","commonSituations":"Forgetting the beam.RegisterType line in main() before beam.Init(); adding a new row struct to an existing pipeline; refactoring that moves the type into another package without re-registering it.","solutions":["Add beam.RegisterType(reflect.TypeOf(MyRow{})) in an init() function or before beam.Init() in main.","Verify the registration happens in the same binary that builds/runs the pipeline.","Check that the type passed to Read/Write is exactly the registered type (not a type alias with a different identity)."],"exampleFix":"// before\nfunc main() {\n    beam.Init()\n    bigqueryio.Write(s, proj, ds, table, col) // col elem type MyRow\n}\n\n// after\ntype MyRow struct{ N int }\nfunc init() {\n    beam.RegisterType(reflect.TypeOf(MyRow{}))\n}\nfunc main() {\n    beam.Init()\n    bigqueryio.Write(s, proj, ds, table, col)\n}","handlingStrategy":"validation","validationCode":"if _, ok := runtime.LookupType(runtime.TypeKey(reflectx.SkipPtr(reflect.TypeOf(MyRow{})))); !ok {\n    beam.RegisterType(reflect.TypeOf(MyRow{}))\n}","typeGuard":null,"tryCatchPattern":"defer func() {\n    if r := recover(); r != nil {\n        if strings.Contains(fmt.Sprint(r), \"is not registered\") {\n            log.Fatalf(\"register the type with beam.RegisterType before beam.Init(): %v\", r)\n        }\n        panic(r)\n    }\n}()","preventionTips":["Put beam.RegisterType calls in each type's package init().","Register every struct used as a PCollection element in distributed pipelines.","Keep beam.Init() after all registrations in main()."],"tags":["go","bigquery","panic","type-registration"],"backgroundTag":"class-not-found","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"}