{"record":{"id":"071c724cdc7bd952","repo":"apache/beam","slug":"failed-to-marshal-iterable-coder-v","errorCode":null,"errorMessage":"failed to marshal iterable coder %v","messagePattern":"failed to marshal iterable coder (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/coder.go","lineNumber":577,"sourceCode":"\t\tcomp := []string{}\n\t\tids, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.SetTopLevelMsgf(err, \"failed to marshal timer coder %v\", c)\n\t\t}\n\t\tcomp = append(comp, ids...)\n\n\t\tid, err := b.AddWindowCoder(c.Window)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal window coder %v\", c)\n\t\t}\n\t\tcomp = append(comp, id)\n\n\t\treturn b.internBuiltInCoder(urnTimerCoder, comp...), nil\n\n\tcase coder.Iterable:\n\t\tcomp, err := b.AddMulti(c.Components)\n\t\tif err != nil {\n\t\t\treturn \"\", errors.Wrapf(err, \"failed to marshal iterable coder %v\", c)\n\t\t}\n\t\treturn b.internBuiltInCoder(urnIterableCoder, comp...), nil\n\n\tdefault:\n\t\terr := errors.Errorf(\"unexpected coder kind: %v\", c.Kind)\n\t\treturn \"\", errors.WithContextf(err, \"failed to marshal coder %v\", c)\n\t}\n}\n\n// AddMulti adds the given coders to the set and returns their ids. Idempotent.\nfunc (b *CoderMarshaller) AddMulti(list []*coder.Coder) ([]string, error) {\n\tvar ids []string\n\tfor _, c := range list {\n\t\tif id, err := b.Add(c); err != nil {\n\t\t\treturn nil, errors.Wrapf(err, \"failed to marshal the coder %v.\", c)\n\t\t} else {\n\t\t\tids = append(ids, id)\n\t\t}","sourceCodeStart":559,"sourceCodeEnd":595,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/coder.go#L559-L595","documentation":"Produced by CoderMarshaller.Add when marshalling a coder.Iterable: it recursively marshals the iterable's component coders via AddMulti, and wraps any failure with \"failed to marshal iterable coder\". The SDK throws it because an iterable coder can only be serialized if all of its component coders serialize successfully.","triggerScenarios":"Add(c) where c.Kind == coder.Iterable and AddMulti(c.Components) fails — e.g. a nested component has an unsupported kind or a failing window coder.","commonSituations":"Pipelines with PCollections of lists/iterables whose element type triggers a nested marshalling error; custom element coders that hit the 'unexpected coder kind' default path; malformed coders built manually.","solutions":["Read the wrapped cause to find which nested component coder failed.","Replace unsupported element types in the iterable with types that have registered encoders.","Register a custom coder via beam.Encoder/beam.Decoder registration for unsupported element types.","Validate the whole pipeline coder with CoderMarshaller.AddMulti before submission to isolate the failing component.","Upgrade to a Beam version that supports the element kind in question."],"exampleFix":"// before\niterCoder := coder.NewI(coder.NewCustomCoder(unknownKind))\n// after\niterCoder := coder.NewI(coder.NewBytes()) // use a coder kind the marshaller supports","handlingStrategy":"validation","validationCode":"for _, comp := range c.Components {\n    if comp == nil {\n        return errors.New(\"iterable has nil component coder\")\n    }\n}","typeGuard":"func isKnownKind(c *coder.Coder) bool {\n    switch c.Kind {\n    case coder.Custom, coder.KV, coder.Window, coder.Timer, coder.Iterable, coder.Bool, coder.Bytes:\n        return true\n    }\n    return false\n}","tryCatchPattern":"ids, err := b.AddMulti(c.Components)\nif err != nil {\n    return \"\", fmt.Errorf(\"iterable coder %v component failed: %w\", c, err)\n}","preventionTips":["Validate nested element types have registered encoders before building pipelines.","Prefer built-in coder kinds for iterable elements.","Test pipeline marshalling locally before submitting to a runner."],"tags":["go","apache-beam","serialization","iterable"],"backgroundTag":"json-marshal-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}