apache/beam · error
unencodable type
Error message
unencodable type '%v'
What it means
The default branch of encodeType returns 'unencodable type %v' for any reflect.Kind not explicitly handled (primitives, string, slice, struct, func, chan, ptr, unsafe pointer, etc. are handled; everything else like complex, uintptr, chan-less kinds fall here). It means the type is outside graphx's supported serialization surface.
Solutions
- Replace the unsupported kind with an encodable one (struct/slice of primitives)
- Represent complex numbers as a struct of two float64 fields
- Remove uintptr/unsafe usage from pipeline types
- Add a custom coder if the type is genuinely needed
Example fix
// before
type Signal struct { Amp complex128 }
// after
type Signal struct { Real, Imag float64 } Defensive patterns
Strategy: validation
Validate before calling
unsupported := map[reflect.Kind]bool{
reflect.Complex64: true, reflect.Complex128: true,
reflect.Uintptr: true, reflect.UnsafePointer: true,
}
if unsupported[t.Kind()] { return fmt.Errorf("kind %v not supported by graphx", t.Kind()) } Prevention
- Avoid complex numbers and uintptr in pipeline data types
- Model complex numbers as struct{Re, Im float64}
- Keep DoFn signatures limited to primitives, strings, slices and structs
When it happens
Trigger: Encoding exotic kinds such as reflect.Complex64/Complex128, reflect.Uintptr, reflect.UnsafePointer, or Invalid as part of a pipeline graph type.
Common situations: Users pass element types containing complex numbers or uintptr values in DoFn signatures; also appears when reflection yields an invalid/zero type from badly constructed generic code.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/b94492eae1c21fe4.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/graphx/serialize.go:511
if err != nil {
wrapped := errors.Wrap(err, "bad channel direction")
return nil, errors.WithContextf(wrapped, "encoding channel %v", t)
}
return &v1pb.Type{Kind: v1pb.Type_CHAN, Element: elm, ChanDir: dir}, nil
case reflect.Ptr:
elm, err := encodeType(t.Elem())
if err != nil {
wrapped := errors.Wrap(err, "bad base type")
return nil, errors.WithContextf(wrapped, "encoding pointer %v", t)
}
return &v1pb.Type{Kind: v1pb.Type_PTR, Element: elm}, nil
case reflect.Map, reflect.Array:
return nil, errors.Errorf("unencodable type '%v', try to wrap the type as a field in a struct, see https://github.com/apache/beam/issues/23101 for details", t.Kind())
default:
return nil, errors.Errorf("unencodable type '%v'", t.Kind())
}
}
func tryEncodeSpecial(t reflect.Type) (v1pb.Type_Special, bool) {
switch t {
case reflectx.Error:
return v1pb.Type_ERROR, true
case reflectx.Context:
return v1pb.Type_CONTEXT, true
case reflectx.Type:
return v1pb.Type_TYPE, true
case typex.EventTimeType:
return v1pb.Type_EVENTTIME, true
case typex.WindowType:
return v1pb.Type_WINDOW, true
case typex.BundleFinalizationType:
return v1pb.Type_BUNDLEFINALIZATION, trueView on GitHub (pinned to 12126d8942)