{"record":{"id":"204e956ce9c0a3dd","repo":"apache/beam","slug":"unable-to-convert-value-of-v-to-schema-field","errorCode":null,"errorMessage":"unable to convert value of %v to schema field","messagePattern":"unable to convert value of (.+?) to schema field","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go","lineNumber":601,"sourceCode":"\t}\n\n\tt := ot\n\tswitch t.Kind() {\n\tcase reflect.Ptr:\n\t\tvt, err := r.reflectTypeToFieldType(t.Elem())\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"unable to convert key of %v to schema field\", ot)\n\t\t}\n\t\tvt.Nullable = true\n\t\treturn vt, nil\n\tcase reflect.Map:\n\t\tkt, err := r.reflectTypeToFieldType(t.Key())\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"unable to convert key of %v to schema field\", ot)\n\t\t}\n\t\tvt, err := r.reflectTypeToFieldType(t.Elem())\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"unable to convert value of %v to schema field\", ot)\n\t\t}\n\t\treturn &pipepb.FieldType{\n\t\t\tTypeInfo: &pipepb.FieldType_MapType{\n\t\t\t\tMapType: &pipepb.MapType{\n\t\t\t\t\tKeyType:   kt,\n\t\t\t\t\tValueType: vt,\n\t\t\t\t},\n\t\t\t},\n\t\t}, nil\n\tcase reflect.Struct:\n\t\tsch, err := r.structToSchema(t)\n\t\tif err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"unable to convert %v to schema field\", ot)\n\t\t}\n\t\treturn &pipepb.FieldType{\n\t\t\tTypeInfo: &pipepb.FieldType_RowType{\n\t\t\t\tRowType: &pipepb.RowType{\n\t\t\t\t\tSchema: sch,","sourceCodeStart":583,"sourceCodeEnd":619,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L583-L619","documentation":"This error wraps a failure that occurred while converting the value type of a Go map type into a Beam pipepb.FieldType during schema encoding in reflectTypeToFieldType. The Beam schema package can only translate types it understands (atomics, registered logical types, structs, maps, slices); if the map's value type is itself unconvertible, the underlying error is wrapped with this message. It is a propagation wrapper, so the root cause is described by the wrapped error.","triggerScenarios":"Calling beam.RegisterLogicalType or any schema encoding path (structToSchema/ToType round trips) on a Go struct containing a map whose value type is an unsupported kind (interface, func, chan, unsafe.Pointer, complex, or invalid), or a nested struct that fails conversion.","commonSituations":"Users define a Podo struct with fields like map[string]func() or map[string]SomeUnregisteredStruct and pass the type to beam.ParDo/beam.Create with schema encoding, or after upgrading Beam a previously registered logical type is no longer registered in the new process.","solutions":["Read the wrapped (inner) error to identify the exact nested type that failed conversion","Change the map value type to a schema-supported type (atomic, slice, map, or struct of supported fields)","Register custom types with schema.RegisterLogicalType (or schema.RegisterAssignableType) so they convert","Implement cache.CustomTypeEncoder/Decoder or use the coder instead of schema encoding if the type cannot be schema-represented"],"exampleFix":"// before\ntype Bad struct { M map[string]func() }\n// after\ntype Good struct { M map[string]string }","handlingStrategy":"validation","validationCode":"func isSchemaSafe(t reflect.Type) error {\n  switch t.Kind() {\n  case reflect.Interface, reflect.Func, reflect.Chan, reflect.UnsafePointer, reflect.Complex128, reflect.Complex64, reflect.Invalid:\n    return fmt.Errorf(\"unsupported kind %v in %v\", t.Kind(), t)\n  case reflect.Map:\n    if err := isSchemaSafe(t.Elem()); err != nil { return err }\n    return isSchemaSafe(t.Key())\n  case reflect.Slice, reflect.Array:\n    return isSchemaSafe(t.Elem())\n  case reflect.Struct:\n    for i := 0; i < t.NumField(); i++ {\n      if err := isSchemaSafe(t.Field(i).Type); err != nil { return err }\n    }\n  }\n  return nil\n}","typeGuard":null,"tryCatchPattern":"_, err := registry.ToType(s)\nvar se *serr\nif errors.As(err, &se) { /* handle schema conversion failure */ }\nif err != nil {\n  if strings.Contains(err.Error(), \"unable to convert value of\") { /* fix map value type */ }\n}","preventionTips":["Keep Podo struct fields limited to atomics, slices, maps, and nested structs","Register all custom types with schema.RegisterLogicalType at package init","Write a unit test that round-trips every payload struct through schema.ToType(schema.FromType(...))"],"tags":["go","apache-beam","schema","type-conversion"],"backgroundTag":"incompatible-source-type","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}