{"record":{"id":"c30c82ce35d37dc9","repo":"apache/beam","slug":"registering-type-for-field-v-in-v","errorCode":null,"errorMessage":"registering type for field %v in %v","messagePattern":"registering type for field (.+?) in (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go","lineNumber":286,"sourceCode":"\t\t}\n\t\tif t != rt {\n\t\t\t// It's only a logical type if it's not a built in primitive type, which is returned by the map.\n\t\t\tr.RegisterLogicalType(ToLogicalType(t.String(), t, rt))\n\t\t}\n\t\treturn nil\n\t}\n\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tsf := ut.Field(i)\n\t\tignore, _, err := ignoreField(t, sf)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\tif ignore {\n\t\t\tcontinue\n\t\t}\n\t\tif err := r.registerType(sf.Type, seen); err != nil {\n\t\t\treturn errors.Wrapf(err, \"registering type for field %v in %v\", sf.Name, ut)\n\t\t}\n\t}\n\n\tschm, err := r.fromType(ut)\n\tif err != nil {\n\t\treturn errors.WithContextf(err, \"converting %v to schema\", ut)\n\t}\n\tsynth, err := r.toType(schm)\n\tif err != nil {\n\t\treturn errors.WithContextf(err, \"converting %v's back to a synthetic type\", ut)\n\t}\n\n\tr.addToMaps(synth, ut)\n\treturn nil\n}\n\n// registerType must only be called when the r.rwmu write Lock is held.\nfunc (r *Registry) addToMaps(synth, ut reflect.Type) {","sourceCodeStart":268,"sourceCodeEnd":304,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L268-L304","documentation":"This is a wrapped error raised inside Registry.registerType while recursively registering the field types of a struct. When converting a struct's field type fails, registerType wraps the underlying error with the field name and enclosing struct so the developer can locate the offending field. It indicates a nested type within a struct field could not be registered for schema encoding.","triggerScenarios":"Calling Registry.FromType (or RegisterDataType/registerType) on a struct whose field contains a nested type that fails registration — e.g. a field whose type reaches an unlisted reflect.Kind, or whose map/slice/pointer element or nested struct conversion fails.","commonSituations":"Using custom Go types (named primitives, maps of maps, pointer chains) as struct fields in PCollection element types; newly unsupported kinds after a Beam upgrade; third-party struct fields containing exotic types.","solutions":["Look at the wrapped (inner) error below this message to find the root cause type/kind.","Change the offending struct field to a schema-serializable type (primitives, strings, slices, maps, nested structs, pointers to structs).","Register a logical type for the custom type via RegisterLogicalType/beam.RegisterSchemaType before pipeline construction.","Mark the field with a schema ignore tag so it is skipped during registration.","Upgrade or patch Beam if the kind is genuinely supported but unlisted in reflectKindToTypeMap."],"exampleFix":"// before\ntype Event struct { ID CustomID }\n// after — register the custom type first, or use a convertible field type\nbeam.RegisterSchemaType(reflect.TypeOf(CustomID{}), \"CustomID\")\ntype Event struct { ID CustomID } // now convertible","handlingStrategy":"validation","validationCode":"func schemaSafe(t reflect.Type) error {\n  switch reflectx.SkipPtr(t).Kind() {\n  case reflect.Struct:\n    for i := 0; i < t.NumField(); i++ {\n      if err := schemaSafe(t.Field(i).Type); err != nil {\n        return fmt.Errorf(\"field %s: %w\", t.Field(i).Name, err)\n      }\n    }\n    return nil\n  case reflect.Map:\n    return schemaSafe(t.Key())\n  case reflect.Slice, reflect.Array, reflect.Ptr:\n    return schemaSafe(t.Elem())\n  case reflect.Chan, reflect.Func, reflect.Complex64, reflect.Complex128:\n    return fmt.Errorf(\"unsupported kind %v\", t.Kind())\n  }\n  return nil\n}","typeGuard":"func isStructOrPtrToStruct(t reflect.Type) bool { return reflectx.SkipPtr(t).Kind() == reflect.Struct }","tryCatchPattern":null,"preventionTips":["Pre-validate PCollection element types with a recursive kind check before building the pipeline.","Keep struct fields to primitives, strings, time.Time, slices, maps, and (pointer-to-)structs.","Register logical types for custom leaf types at package init.","Use beam schema ignore tags for non-serializable fields.","Unwrap error chains to the root cause before debugging."],"tags":["go","schema","reflection","type-registration"],"backgroundTag":"schema-validation-failed","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"}