{"record":{"id":"ad04718e5a069728","repo":"apache/beam","slug":"failed-to-expand-reshuffle-transform-for-edge-v","errorCode":null,"errorMessage":"failed to expand Reshuffle transform for edge: %v","messagePattern":"failed to expand Reshuffle transform for edge: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/graphx/translate.go","lineNumber":971,"sourceCode":"// In particular, the \"backup plan\" needs to:\n//\n//   - Encode the windowed element, preserving timestamps.\n//   - Add random keys to the encoded windowed element []bytes\n//   - GroupByKey (in the global window).\n//   - Explode the resulting elements list.\n//   - Decode the windowed element []bytes.\n//\n// While a simple reshard can be written in user terms, (timestamps and windows\n// are accessible to user functions) there are some framework internal\n// optimizations that can be done if the framework is aware of the reshard, though\n// ideally this is handled on the runner side.\n//\n// User code is able to write reshards, but it's easier to access\n// the window coders framework side, which is critical for the reshard\n// to function with unbounded inputs.\nfunc (m *marshaller) expandReshuffle(edge NamedEdge) (string, error) {\n\thandleErr := func(err error) (string, error) {\n\t\treturn \"\", errors.Wrapf(err, \"failed to expand Reshuffle transform for edge: %v\", edge)\n\t}\n\tid := edgeID(edge.Edge)\n\tkvCoder, err := makeUnionCoder()\n\tif err != nil {\n\t\treturn handleErr(err)\n\t}\n\tkvCoderID, err := m.coders.Add(kvCoder)\n\tif err != nil {\n\t\treturn handleErr(err)\n\t}\n\tgbkCoderID, err := m.coders.Add(coder.NewCoGBK(kvCoder.Components))\n\tif err != nil {\n\t\treturn handleErr(err)\n\t}\n\n\tvar subtransforms []string\n\n\tin := edge.Edge.Input[0]","sourceCodeStart":953,"sourceCodeEnd":989,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/graphx/translate.go#L953-L989","documentation":"expandReshuffle translates beam.Reshuffle into a GBK-with-union-coder + re-window pattern; the framework must construct window coders for the reshard to work with unbounded inputs. Failures constructing the union coder, re-windowing transforms, or their nodes are wrapped as 'failed to expand Reshuffle transform for edge: %v'.","triggerScenarios":"Calling beam.Reshuffle on a PCollection whose windowing strategy cannot be marshalled into the union coder's window coder (makeWindowCoder failure), or where intermediate node creation fails.","commonSituations":"Reshuffle on PCollections with exotic/unsupported windowing (e.g. custom window functions); runner environments where window coders for unbounded streams can't be built; SDK version mismatches.","solutions":["Check the wrapped inner error — usually makeUnionCoder or makeWindowCoder failure","Ensure the input uses a supported window kind (global/fixed/sliding/session), not a custom WindowFn","Replace beam.Reshuffle with an alternative resharding approach (e.g. GBK with a dummy key) if windowing is custom","Upgrade the Go SDK for newer windowing support"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"// reshuffle only supports standard window kinds\nif w.Kind != window.GlobalWindows && w.Kind != window.FixedWindows &&\n   w.Kind != window.SlidingWindows && w.Kind != window.SessionWindows {\n    return errors.New(\"reshuffle requires a standard window function\")\n}","typeGuard":"func isSupportedWindow(w *window.Fn) bool {\n    switch w.Kind {\n    case window.GlobalWindows, window.FixedWindows, window.SlidingWindows, window.SessionWindows:\n        return true\n    }\n    return false\n}","tryCatchPattern":"if err := beam.Run(ctx, pr); err != nil {\n    if strings.Contains(err.Error(), \"failed to expand Reshuffle transform\") {\n        return fmt.Errorf(\"reshuffle incompatible with windowing: %w\", err)\n    }\n    return err\n}","preventionTips":["Only apply beam.Reshuffle to PCollections with built-in window functions","Avoid custom WindowFn + Reshuffle combinations","Prefer a keyed GBK reshard when custom windowing is required"],"tags":["go","apache-beam","reshuffle","windowing"],"backgroundTag":"coder-registration-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"}