{"record":{"id":"b8d93a44511c4ed6","repo":"apache/beam","slug":"reconciling-for-totype","errorCode":null,"errorMessage":"reconciling for ToType","messagePattern":"reconciling for ToType","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go","lineNumber":692,"sourceCode":"\treflect.Int:     reflectx.Int,\n\treflect.Int8:    reflectx.Int8,\n\treflect.Int16:   reflectx.Int16,\n\treflect.Int32:   reflectx.Int32,\n\treflect.Int64:   reflectx.Int64,\n\treflect.Float32: reflectx.Float32,\n\treflect.Float64: reflectx.Float64,\n\treflect.String:  reflectx.String,\n\treflect.Bool:    reflectx.Bool,\n}\n\nvar emptyStructType = reflect.TypeOf((*struct{})(nil)).Elem()\n\n// ToType returns a Go type of the passed in Schema.\n// Types returned by ToType are always of Struct kind.\n// Returns an error if the Schema cannot be converted to a type.\nfunc (r *Registry) ToType(s *pipepb.Schema) (reflect.Type, error) {\n\tif err := r.reconcileRegistrations(); err != nil {\n\t\treturn nil, errors.Wrap(err, \"reconciling for ToType\")\n\t}\n\tr.rwmu.RLock()\n\tdefer r.rwmu.RUnlock()\n\treturn r.toType(s)\n}\n\n// toType must only be called while holding the r.rwmu lock (read or write)\nfunc (r *Registry) toType(s *pipepb.Schema) (reflect.Type, error) {\n\tif t, ok := r.idToType[s.GetId()]; ok {\n\t\treturn t, nil\n\t}\n\tif lID, ok := fromLogicalOption(s.GetOptions()); ok {\n\t\tif lt, ok := r.logicalTypes[lID]; ok {\n\t\t\treturn lt.GoType(), nil\n\t\t}\n\t}\n\n\tfields := make([]reflect.StructField, 0, len(s.GetFields()))","sourceCodeStart":674,"sourceCodeEnd":710,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L674-L710","documentation":"Wraps any failure from Registry.reconcileRegistrations() when calling the public Registry.ToType(s). Reconciliation processes pending logical-type registrations into lookup tables; if that internal step fails (duplicate URNs, malformed registered types, conversion errors), ToType cannot proceed and this wrapper is returned.","triggerScenarios":"Calling registry.ToType(schema) after one or more RegisterLogicalType calls where reconciliation fails — e.g. a registered logical type whose To/From functions reference types that themselves fail schema conversion, or a duplicate URN.","commonSituations":"Applications registering logical types at init time across multiple packages; an init-order or bad registration surfaces only later when ToType is invoked during pipeline construction or cross-language type translation.","solutions":["Inspect the wrapped inner error — it names the registration that failed to reconcile","Verify all RegisterLogicalType calls use unique URNs and valid type providers","Ensure registered logical types' metadata schemas can themselves be converted (no unsupported kinds)","Call reconcileRegistrations-triggering APIs early (e.g. in tests) to surface registration bugs at init"],"exampleFix":"// before (duplicate URN registered twice)\nschema.RegisterLogicalType(myTypeA) // urn \"acme:foo\"\nschema.RegisterLogicalType(myTypeB) // same urn \"acme:foo\"\n// after\nschema.RegisterLogicalType(myTypeB) // use a distinct URN \"acme:bar\"","handlingStrategy":"try-catch","validationCode":"func init() {\n  // exercise reconciliation early\n  if _, err := registry.ToType(&pipepb.Schema{}); err != nil {\n    panic(\"logical type registration broken: \" + err.Error())\n  }\n}","typeGuard":null,"tryCatchPattern":"t, err := registry.ToType(s)\nif err != nil {\n  return nil, fmt.Errorf(\"ToType failed during registration reconcile: %w\", err)\n}","preventionTips":["Register logical types exactly once with unique URNs","Add an init-time smoke test that forces reconcileRegistrations","Avoid registering logical types whose conversion functions themselves fail schema conversion"],"tags":["go","apache-beam","schema","registry","logical-type"],"backgroundTag":"invalid-state-transition","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"}