{"record":{"id":"14345e9d8900a654","repo":"apache/beam","slug":"unable-to-encode-type-v","errorCode":null,"errorMessage":"unable to encode type: %v","messagePattern":"unable to encode type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/coder/row_encoder.go","lineNumber":260,"sourceCode":"\t\treturn typeEncoderFieldReflect{encode: iterableEncoder(t, encf)}, nil\n\tcase reflect.Array:\n\t\tencf, err := b.containerEncoderForType(t.Elem())\n\t\tif err != nil {\n\t\t\treturn typeEncoderFieldReflect{}, err\n\t\t}\n\t\treturn typeEncoderFieldReflect{encode: iterableEncoder(t, encf)}, nil\n\tcase reflect.Map:\n\t\tencK, err := b.containerEncoderForType(t.Key())\n\t\tif err != nil {\n\t\t\treturn typeEncoderFieldReflect{}, err\n\t\t}\n\t\tencV, err := b.containerEncoderForType(t.Elem())\n\t\tif err != nil {\n\t\t\treturn typeEncoderFieldReflect{}, err\n\t\t}\n\t\treturn typeEncoderFieldReflect{encode: mapEncoder(t, encK, encV)}, nil\n\t}\n\treturn typeEncoderFieldReflect{}, errors.Errorf(\"unable to encode type: %v\", t)\n}\n\nfunc (b *RowEncoderBuilder) containerEncoderForType(t reflect.Type) (typeEncoderFieldReflect, error) {\n\tencf, err := b.encoderForSingleTypeReflect(t)\n\tif err != nil {\n\t\treturn typeEncoderFieldReflect{}, err\n\t}\n\tif t.Kind() == reflect.Ptr {\n\t\treturn typeEncoderFieldReflect{encode: NullableEncoder(encf.encode), addr: encf.addr}, nil\n\t}\n\treturn encf, nil\n}\n\ntype typeEncoderReflect struct {\n\tdebug  []string\n\tfields []typeEncoderFieldReflect\n}\n","sourceCodeStart":242,"sourceCodeEnd":278,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/coder/row_encoder.go#L242-L278","documentation":"The RowEncoderBuilder cannot build a reflective encoder for the given Go type: its kind is not in the supported set for Beam schema row encoding. Same family as the decoder counterpart but on the encode path.","triggerScenarios":"Calling EncoderForSlice / encoderForStructReflect / containerEncoderForType on a type whose kind (e.g. chan, func, unsafe.Pointer, nested unsupported element) has no encoder case.","commonSituations":"A PCollection element struct contains an unsupported field type and the user relies on default schema coding.","solutions":["Restrict element types to schema-encodable kinds (primitives, strings, bytes, slices, maps, arrays, structs)","Provide a custom coder via beam.EncodedCustomCoder or register a schema creator/type","Strip or transform unsupported fields before encoding"],"exampleFix":"// before\ntype Point struct { Mutex sync.Mutex }\n// after\ntype Point struct { X, Y float64 }","handlingStrategy":"validation","validationCode":"func encodable(t reflect.Type) bool {\n    switch t.Kind() {\n    case reflect.Chan, reflect.Func, reflect.Interface, reflect.UnsafePointer:\n        return false\n    }\n    return true\n}","typeGuard":"func isRowEncodable(v any) bool { return encodable(reflect.TypeOf(v)) }","tryCatchPattern":"if _, err := (coder.RowEncoderBuilder{}).Build(t); err != nil {\n    return fmt.Errorf(\"type %T not row-encodable: %w\", v, err)\n}","preventionTips":["Test round-trip encoding of every element type in CI","Keep element structs free of mutexes, channels, and funcs","Fall back to custom coders for exotic types"],"tags":["go","beam","reflection","coder"],"backgroundTag":"unsupported-operation","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"}