{"record":{"id":"5448c8548fa1fb1c","repo":"apache/beam","slug":"bad-base-type","errorCode":null,"errorMessage":"bad base type","messagePattern":"bad base type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/serialize.go","lineNumber":502,"sourceCode":"\t\treturn &v1pb.Type{Kind: v1pb.Type_FUNC, ParameterTypes: in, ReturnTypes: out, IsVariadic: t.IsVariadic()}, nil\n\n\tcase reflect.Chan:\n\t\telm, err := encodeType(t.Elem())\n\t\tif err != nil {\n\t\t\twrapped := errors.Wrap(err, \"bad element type\")\n\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding channel %v\", t)\n\t\t}\n\t\tdir, err := encodeChanDir(t.ChanDir())\n\t\tif err != nil {\n\t\t\twrapped := errors.Wrap(err, \"bad channel direction\")\n\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding channel %v\", t)\n\t\t}\n\t\treturn &v1pb.Type{Kind: v1pb.Type_CHAN, Element: elm, ChanDir: dir}, nil\n\n\tcase reflect.Ptr:\n\t\telm, err := encodeType(t.Elem())\n\t\tif err != nil {\n\t\t\twrapped := errors.Wrap(err, \"bad base type\")\n\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding pointer %v\", t)\n\t\t}\n\t\treturn &v1pb.Type{Kind: v1pb.Type_PTR, Element: elm}, nil\n\n\tcase reflect.Map, reflect.Array:\n\t\treturn 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())\n\n\tdefault:\n\t\treturn nil, errors.Errorf(\"unencodable type '%v'\", t.Kind())\n\t}\n}\n\nfunc tryEncodeSpecial(t reflect.Type) (v1pb.Type_Special, bool) {\n\tswitch t {\n\tcase reflectx.Error:\n\t\treturn v1pb.Type_ERROR, true\n\tcase reflectx.Context:\n\t\treturn v1pb.Type_CONTEXT, true","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/serialize.go#L484-L520","documentation":"In the Beam Go SDK's graphx type serialization, encodeType recursively encodes reflect.Type values into protobuf form. When encoding a pointer's base (element) type fails, the inner error is wrapped with 'bad base type' and contextualized with 'encoding pointer %v'. It indicates the pointed-to type itself is not serializable by graphx.","triggerScenarios":"Pipelines whose graph contains a pointer type (e.g. *T as an input/output or nested inside another type) where T itself fails encodeType — for example *map[string]int or *[10]int, since Map and Array are unencodable at top level.","commonSituations":"Users declare DoFn parameters or PCollection elements as pointers to inherently unencodable types (maps, arrays) instead of wrapping them in a struct; surfaces during pipeline submission/marshalling of the model graph.","solutions":["Change the pointed-to type to an encodable kind (struct, slice, primitive)","Wrap the map/array in a struct field, per https://github.com/apache/beam/issues/23101","Inspect the full wrapped error chain (base error + 'encoding pointer %v' context) to find the offending type","Register a custom coder for the type via beam.CustomCoder if the type must be kept"],"exampleFix":"// before\nvar x *[10]int\npc := beam.ParDo(s, extractFn, beam.Create(s, x))\n// after\ntype IntArray struct { V [10]int }\npc := beam.ParDo(s, extractFn, beam.Create(s, IntArray{}))","handlingStrategy":"validation","validationCode":"func isEncodableType(t reflect.Type) bool {\n\tswitch t.Kind() {\n\tcase reflect.Ptr:\n\t\treturn isEncodableType(t.Elem())\n\tcase reflect.Map, reflect.Array:\n\t\treturn false\n\tcase reflect.Slice, reflect.Struct:\n\t\tif t.Kind() == reflect.Struct {\n\t\t\tfor i := 0; i < t.NumField(); i++ {\n\t\t\t\tif !isEncodableType(t.Field(i).Type) { return false }\n\t\t\t}\n\t\t}\n\t\treturn true\n\tdefault:\n\t\treturn graphx.TryEncodeSpecial(t) != 0 || isKnownKind(t.Kind())\n\t}\n}","typeGuard":"func isEncodable(t reflect.Type) bool { return isEncodableType(t) }","tryCatchPattern":null,"preventionTips":["Avoid pointer-typed PCollection elements; pass values","Never use raw map or array types as pipeline element types","Wrap complex containers in structs, per beam issue 23101","Test pipeline marshalling locally (graphx.Marshal) before submitting"],"tags":["go","serialization","apache-beam"],"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"}