{"record":{"id":"edef0ef72dd4e39d","repo":"apache/beam","slug":"marshalling-of-v-failed","errorCode":null,"errorMessage":"marshalling of %v failed","messagePattern":"marshalling of (.+?) failed","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/create.go","lineNumber":98,"sourceCode":"\treturn createList(s, ret, t)\n}\n\nfunc addCreateCtx(err error, s Scope) error {\n\treturn errors.WithContextf(err, \"inserting Create in scope %s\", s)\n}\n\nfunc createList(s Scope, values []any, t reflect.Type) (PCollection, error) {\n\tfn := &createFn{Type: EncodedType{T: t}}\n\tenc := NewElementEncoder(t)\n\n\tfor i, value := range values {\n\t\tif other := reflect.ValueOf(value).Type(); other != t {\n\t\t\terr := errors.Errorf(\"value %v at index %v has type %v, want %v\", value, i, other, t)\n\t\t\treturn PCollection{}, addCreateCtx(err, s)\n\t\t}\n\t\tvar buf bytes.Buffer\n\t\tif err := enc.Encode(value, &buf); err != nil {\n\t\t\terr = errors.Wrapf(err, \"marshalling of %v failed\", value)\n\t\t\treturn PCollection{}, addCreateCtx(err, s)\n\t\t}\n\t\tfn.Values = append(fn.Values, buf.Bytes())\n\t}\n\n\timp := Impulse(s)\n\n\tret, err := TryParDo(s, fn, imp, TypeDefinition{Var: TType, T: t})\n\tif err != nil || len(ret) != 1 {\n\t\tpanic(addCreateCtx(errors.WithContext(err, \"internal error\"), s))\n\t}\n\treturn ret[0], nil\n}\n\n// TODO(herohde) 6/26/2017: make 'create' a SDF once supported. See BEAM-2421.\n\ntype createFn struct {\n\tValues [][]byte    `json:\"values\"`","sourceCodeStart":80,"sourceCodeEnd":116,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/create.go#L80-L116","documentation":"After the per-element type check, createList encodes each value with the element encoder. This error wraps a failure of ElementEncoder.Encode, meaning a value of the correct type could not be serialized into the pipeline's coder representation.","triggerScenarios":"Encoding a value whose type has no registered element encoder (unsupported custom struct without a coder), a custom coder's Encode method returning an error, or an underlying io.Writer failure.","commonSituations":"beam.Create on structs with unencodable fields or without a registered custom coder, encoding via a coder registered for a different type, or graph-construction-time coder registration bugs.","solutions":["Register a custom ElementEncoder/coder for the value's type via graph coders or use an encodable type (primitives, protos, registered types)","Simplify the element type to one with built-in encoding support","Check the wrapped inner error to see which coder failed and fix its Encode implementation"],"exampleFix":"// before\npc, err := beam.TryCreate(s, []MyComplexStruct{...}) // no coder registered\n// after\nbeam.RegisterCoder(reflect.TypeOf((*MyComplexStruct)(nil)).Elem(), encMyStruct, decMyStruct)\npc, err := beam.TryCreate(s, []MyComplexStruct{...})","handlingStrategy":"try-catch","validationCode":"enc := beam.NewElementEncoder(t); var b bytes.Buffer; for _, v := range values { if err := enc.Encode(v, &b); err != nil { return err } }","typeGuard":null,"tryCatchPattern":"pc, err := beam.TryCreate(s, values)\nif err != nil {\n    if strings.Contains(err.Error(), \"marshalling of\") { /* register a coder for the element type or simplify the type */ }\n    return PCollection{}, err\n}","preventionTips":["Register custom coders (beam.RegisterCoder) for application structs used in Create","Prefer primitives, strings, and registered proto types as Create elements","Test Create round-trips for new element types during development"],"tags":["beam","encoding","serialization"],"backgroundTag":"serialization-failed","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"}