apache/beam · error
unexpected windowing strategy
Error message
unexpected windowing strategy: %v
What it means
When marshalling a windowing strategy, MarshalWindowingStrategy switches on the window Fn's Kind and emits the corresponding runner-API payload (GlobalWindows, FixedWindows, SlidingWindows, SessionWindows). The default branch throws 'unexpected windowing strategy: %v' when the kind is none of these — i.e. a custom or unknown window function that has no runner-API representation.
Solutions
- Replace the custom window function with one of the supported kinds (global, fixed, sliding, session)
- If a custom window is essential, implement marshalling for it in MarshalWindowingStrategy (contribute upstream)
- Check SDK versions on both producer and consumer of the pipeline for kind mismatches
- File an issue on apache/beam if a standard window kind is unexpectedly unhandled
Example fix
// before — custom window fn custom := window.NewCustomFn(...) pc := beam.WindowInto(s, custom, input) // after — use a supported window kind pc := beam.WindowInto(s, window.FixedWindows(30*time.Second), input)
Defensive patterns
Strategy: validation
Validate before calling
// verify the window kind is one of the four supported kinds before WindowInto
switch fn.Kind {
case window.GlobalWindows, window.FixedWindows, window.SlidingWindows, window.SessionWindows:
// ok
default:
return fmt.Errorf("window kind %v unsupported by Go marshaller", fn.Kind)
} Type guard
func isMarshalableWindowKind(k window.Kind) bool {
return k == window.GlobalWindows || k == window.FixedWindows ||
k == window.SlidingWindows || k == window.SessionWindows
} Try / catch
defer func() {
if r := recover(); r != nil { /* marshalling panics */ }
}()
if err := beam.Run(ctx, pr); err != nil && strings.Contains(err.Error(), "unexpected windowing strategy") {
return fmt.Errorf("custom WindowFn not supported; use global/fixed/sliding/session: %w", err)
} Prevention
- Never submit pipelines with custom WindowFn implementations to remote runners
- Map custom windowing needs onto the four supported kinds
- Keep all SDK versions aligned to the same Beam release
When it happens
Trigger: Applying a custom window.WindowFn (any Kind outside GlobalWindows/FixedWindows/SlidingWindows/SessionWindows) to a PCollection and then marshalling the pipeline (beam.Run or graphx.Marshal).
Common situations: Implementing a custom WindowFn in Go and submitting to a runner; copying pipelines from other SDKs with window kinds the Go marshaller doesn't cover; running older SDK code against pipelines built with newer window kinds.
Related errors
- AfterProcessingTime trigger set without a delay or…
- attempted to add namespace to missing windowing strategy id
- batch: unknown sizer kind
- could not unmarshal global window coder
- could not unmarshal window coder for pcollection
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/5d0bee76d4032280.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/runtime/graphx/translate.go:1465
Urn: URNSlidingWindowsWindowFn,
Payload: protox.MustEncode(
&pipepb.SlidingWindowsPayload{
Size: durationpb.New(w.Size),
Period: durationpb.New(w.Period),
},
),
}, nil
case window.Sessions:
return &pipepb.FunctionSpec{
Urn: URNSessionsWindowFn,
Payload: protox.MustEncode(
&pipepb.SessionWindowsPayload{
GapSize: durationpb.New(w.Gap),
},
),
}, nil
default:
return nil, errors.Errorf("unexpected windowing strategy: %v", w)
}
}
func makeWindowCoder(w *window.Fn) (*coder.WindowCoder, error) {
switch w.Kind {
case window.GlobalWindows:
return coder.NewGlobalWindow(), nil
case window.FixedWindows, window.SlidingWindows, window.Sessions, URNSlidingWindowsWindowFn:
return coder.NewIntervalWindow(), nil
default:
return nil, errors.Errorf("unexpected windowing strategy for coder: %v", w)
}
}
func mustEncodeMultiEdgeBase64(edge *graph.MultiEdge) (string, error) {
ref, err := EncodeMultiEdge(edge)
if err != nil {
return "", errors.Wrapf(err, "failed to serialize %v", edge)View on GitHub (pinned to 12126d8942)