{"record":{"id":"b0d232ff109b90b1","repo":"apache/beam","slug":"cannot-convert-field-v-to-schema","errorCode":null,"errorMessage":"cannot convert field %v to schema","messagePattern":"cannot convert field (.+?) to schema","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go","lineNumber":535,"sourceCode":"\t\tschm.Id = getUUID(t)\n\t\tr.typeToSchema[t] = schm\n\t\tr.idToType[schm.GetId()] = t\n\t\treturn schm, nil\n\t}\n\n\tfields := make([]*pipepb.Field, 0, t.NumField())\n\tfor i := 0; i < t.NumField(); i++ {\n\t\tsf := t.Field(i)\n\t\tignore, isAnon, err := ignoreField(t, sf)\n\t\tif err != nil {\n\t\t\treturn nil, err\n\t\t}\n\t\tif ignore {\n\t\t\tcontinue\n\t\t}\n\t\tf, err := r.structFieldToField(sf)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"cannot convert field %v to schema\", t.Field(i).Name)\n\t\t}\n\t\tif isAnon {\n\t\t\tf = proto.Clone(f).(*pipepb.Field)\n\t\t\tf.Options = append(f.Options, optGoEmbedded())\n\t\t}\n\t\tfields = append(fields, f)\n\t}\n\n\tschm := &pipepb.Schema{\n\t\tFields: fields,\n\t\tId:     getUUID(t),\n\t}\n\tr.idToType[schm.GetId()] = t\n\tr.typeToSchema[t] = schm\n\treturn schm, nil\n}\n\nfunc (r *Registry) structFieldToField(sf reflect.StructField) (*pipepb.Field, error) {","sourceCodeStart":517,"sourceCodeEnd":553,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L517-L553","documentation":"Wraps any error from structFieldToField while converting one struct field, naming the failing field. It means a single field of the struct (its type needing a logical type, map, or nested conversion that fails) prevented the whole struct from becoming a Beam schema. The root cause is always in the wrapped inner error.","triggerScenarios":"Calling FromType on a struct where some field's type cannot be represented as a schema field: unsupported kinds (chan, func, complex), failing logical-type providers, unconvertible map keys/values, or nested pointer chains failing in reflectTypeToFieldType.","commonSituations":"PCollection element structs containing exotic field types; fields added by dependency upgrades; embedded or tagged structs misconfigured; unregistered custom types used as fields.","solutions":["Read the wrapped error to identify the exact failing field type.","Change the field to a convertible type or register a logical type for it.","Add a schema ignore tag (e.g. `beam:\"dropped\"`) to the offending field if it need not be serialized.","Restrict fields to schema-encodable types (primitives, string, time.Time, slices, maps, nested structs/pointers)."],"exampleFix":"// before\ntype Row struct { Fn func() } // unconvertible field\n// after\ntype Row struct {\n    Fn func() `beam:\"dropped\"`\n}","handlingStrategy":"validation","validationCode":"for i := 0; i < t.NumField(); i++ {\n    if err := schemaSafe(t.Field(i).Type); err != nil {\n        return fmt.Errorf(\"field %s of %v not schema-safe: %w\", t.Field(i).Name, t, err)\n    }\n}","typeGuard":"func allFieldsSchemaSafe(t reflect.Type) bool {\n    for i := 0; i < t.NumField(); i++ {\n        if schemaSafe(t.Field(i).Type) != nil { return false }\n    }\n    return true\n}","tryCatchPattern":"schm, err := reg.FromType(t)\nif err != nil && strings.Contains(err.Error(), \"cannot convert field\") {\n    var fe *fieldError\n    if errors.As(err, &fe) { return nil, fmt.Errorf(\"fix field %s: %w\", fe.Name, err) }\n}","preventionTips":["Keep struct fields to schema-encodable types.","Tag non-serializable fields with a beam ignore tag.","Re-validate structs after dependency upgrades add fields.","Register logical types for custom field types at init."],"tags":["go","schema","struct","reflection"],"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-14T16:17:12.679Z"}