{"record":{"id":"f63743d4b57efe11","repo":"apache/beam","slug":"bad-parameter-type","errorCode":null,"errorMessage":"bad parameter type","messagePattern":"bad parameter type","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/serialize.go","lineNumber":470,"sourceCode":"\t\t\tfield := &v1pb.Type_StructField{\n\t\t\t\tName:      f.Name,\n\t\t\t\tPkgPath:   f.PkgPath,\n\t\t\t\tType:      fType,\n\t\t\t\tTag:       string(f.Tag),\n\t\t\t\tOffset:    int64(f.Offset),\n\t\t\t\tIndex:     encodeInts(f.Index),\n\t\t\t\tAnonymous: f.Anonymous,\n\t\t\t}\n\t\t\tfields = append(fields, field)\n\t\t}\n\t\treturn &v1pb.Type{Kind: v1pb.Type_STRUCT, Fields: fields}, nil\n\n\tcase reflect.Func:\n\t\tvar in []*v1pb.Type\n\t\tfor i := 0; i < t.NumIn(); i++ {\n\t\t\tparam, err := encodeType(t.In(i))\n\t\t\tif err != nil {\n\t\t\t\twrapped := errors.Wrap(err, \"bad parameter type\")\n\t\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding function %v\", t)\n\t\t\t}\n\t\t\tin = append(in, param)\n\t\t}\n\t\tvar out []*v1pb.Type\n\t\tfor i := 0; i < t.NumOut(); i++ {\n\t\t\tret, err := encodeType(t.Out(i))\n\t\t\tif err != nil {\n\t\t\t\twrapped := errors.Wrap(err, \"bad return type\")\n\t\t\t\treturn nil, errors.WithContextf(wrapped, \"encoding function %v\", t)\n\t\t\t}\n\t\t\tout = append(out, ret)\n\t\t}\n\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 {","sourceCodeStart":452,"sourceCodeEnd":488,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/serialize.go#L452-L488","documentation":"encodeType serializes func types by encoding each parameter type in turn; 'bad parameter type' means one of the function's input types failed to encode. This occurs while serializing DoFn/processFn signatures during pipeline graph export.","triggerScenarios":"A user function (beam.Par / DoFn ProcessElement method) has an input parameter whose type cannot be encoded by encodeType (map/array parameter, struct parameter with unexported fields, unregistered type).","commonSituations":"DoFns accepting map parameters; functions taking custom struct types with unexported fields; signatures using types unknown to the Beam type registry when running on remote runners.","solutions":["Change the offending parameter type to an encodable one (slice or exported-field struct).","Register the parameter's custom type so it serializes as an EXTERNAL type.","Convert map/array parameters into struct-wrapped or slice forms before passing to the DoFn.","Follow the wrapped error context ('encoding function %v') to identify which parameter fails."],"exampleFix":"// before\nfunc process(ctx context.Context, m map[string]string) error { ... }\n// after\ntype Attr struct { K, V string }\nfunc process(ctx context.Context, attrs []Attr) error { ... }","handlingStrategy":"validation","validationCode":"ft := reflect.TypeOf(fn)\nfor i := 0; i < ft.NumIn(); i++ {\n    if err := isEncodableType(ft.In(i)); err != nil {\n        return fmt.Errorf(\"param %d of %v unencodable: %w\", i, ft, err)\n    }\n}","typeGuard":"func encodableParams(fn any) bool { t := reflect.TypeOf(fn); if t.Kind() != reflect.Func { return false }; for i := 0; i < t.NumIn(); i++ { if isEncodableType(t.In(i)) != nil { return false } }; return true }","tryCatchPattern":"if !encodableParams(fn) {\n    return fmt.Errorf(\"function %T has unserializable parameter types\", fn)\n}","preventionTips":["Avoid map/array parameters in DoFn signatures","Ensure struct parameters have only exported fields","Check that special parameters (context, emit funcs) come from beam's supported set"],"tags":["go","apache-beam","serialization","function-signature"],"backgroundTag":"unencodable-reflect-type","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"}