{"record":{"id":"847f6e0fcf4ee13f","repo":"apache/beam","slug":"unable-to-convert-element-type-of-v-to-schema-field","errorCode":null,"errorMessage":"unable to convert element type of %v to schema field","messagePattern":"unable to convert element type of (.+?) to schema field","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go","lineNumber":634,"sourceCode":"\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,\n\t\t\t\t},\n\t\t\t},\n\t\t}, nil\n\tcase reflect.Slice, reflect.Array:\n\t\t// Special handling for []byte\n\t\tif t == reflectx.ByteSlice {\n\t\t\treturn &pipepb.FieldType{\n\t\t\t\tTypeInfo: &pipepb.FieldType_AtomicType{\n\t\t\t\t\tAtomicType: pipepb.AtomicType_BYTES,\n\t\t\t\t},\n\t\t\t}, nil\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 element type of %v to schema field\", ot)\n\t\t}\n\t\treturn &pipepb.FieldType{\n\t\t\tTypeInfo: &pipepb.FieldType_ArrayType{\n\t\t\t\tArrayType: &pipepb.ArrayType{\n\t\t\t\t\tElementType: vt,\n\t\t\t\t},\n\t\t\t},\n\t\t}, nil\n\tcase reflect.Interface, reflect.Func, reflect.Chan, reflect.UnsafePointer, reflect.Complex128, reflect.Complex64, reflect.Invalid:\n\t\treturn nil, errors.Errorf(\"unable to convert unsupported type %v to schema\", ot)\n\tdefault: // must be an atomic type\n\t\tif enum, ok := reflectTypeToAtomicTypeMap[t.Kind()]; ok {\n\t\t\treturn &pipepb.FieldType{\n\t\t\t\tTypeInfo: &pipepb.FieldType_AtomicType{\n\t\t\t\t\tAtomicType: enum,\n\t\t\t\t},\n\t\t\t}, nil\n\t\t}","sourceCodeStart":616,"sourceCodeEnd":652,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/schema/schema.go#L616-L652","documentation":"This wrapper error is raised when the element type of a Go slice/array cannot be converted to a Beam FieldType in reflectTypeToFieldType. The slice itself is fine; the failure comes from recursively converting t.Elem(), and this message adds the owning slice type for context.","triggerScenarios":"Encoding a struct field or type like []T where T is an unsupported kind (interface, func, chan, complex) or a nested struct whose conversion fails.","commonSituations":"Users have fields like []io.Reader, []interface{}, or [][]chan int inside a Podo passed to schema-based encoding.","solutions":["Check the wrapped error for the concrete element type that failed","Replace the element type with a schema-supported concrete type","Register a logical/assignable type for the element if it must be preserved","Serialize unsupported elements to bytes/string manually before encoding"],"exampleFix":"// before\ntype T struct { Readers []io.Reader }\n// after\ntype T struct { Data [][]byte }","handlingStrategy":"validation","validationCode":"if t.Kind() == reflect.Slice && !isSchemaSafe(t.Elem()) { /* fix before encoding */ }","typeGuard":null,"tryCatchPattern":"ft, err := schema.FromType(sliceType)\nif err != nil && strings.Contains(err.Error(), \"element type\") {\n  return fmt.Errorf(\"slice element not schema-supported: %w\", err)\n}","preventionTips":["Never use []interface{} or []io.Reader as struct fields in pipeline payloads","Prefer concrete element types ([]byte, []string, []MyStruct)","Register element logical types at init if custom types are required"],"tags":["go","apache-beam","schema","slice"],"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-14T16:17:12.679Z"}