apache/beam · error

window coder with unexpected type

Error message

window coder with unexpected type %v

What it means

Produced by CoderMarshaller.AddWindowCoder when the window coder's Kind is neither GlobalWindow nor IntervalWindow. The marshaller only knows how to emit model URNs for those two window kinds, so any other kind fails with this error and is wrapped with 'failed to unmarshal window coder'.

Solutions

  1. Log w.Kind to see which window type was rejected.
  2. Use beam.GlobalWindows or beam.FixedWindows/SlidingWindows (IntervalWindow) windowing.
  3. Remove custom window kinds from the pipeline or implement serialization support in AddWindowCoder.
  4. Verify the windowing strategy assigned to the PCollection is a built-in Beam window function.
  5. Upgrade Beam if the window kind is newly supported upstream.

Example fix

// before
w := coder.WindowCoder{Kind: myCustomWindowKind}
// after
w := coder.NewIntervalWindowCoder() // or coder.NewGlobalWindowCoder()
Defensive patterns

Strategy: type-guard

Validate before calling

if w.Kind != coder.GlobalWindow && w.Kind != coder.IntervalWindow {
    return errors.New("window kind must be GlobalWindow or IntervalWindow")
}

Type guard

func isSupportedWindowKind(w *coder.WindowCoder) bool {
    return w != nil && (w.Kind == coder.GlobalWindow || w.Kind == coder.IntervalWindow)
}

Try / catch

id, err := b.AddWindowCoder(w)
if err != nil {
    return "", fmt.Errorf("window coder %v unsupported (kind=%v): %w", w, w.Kind, err)
}

Prevention

When it happens

Trigger: AddWindowCoder(w) (called from Add for windowed coders, expandReshuffle, or MarshalWindowingStrategy) with a coder whose w.Kind is an unimplemented window type.

Common situations: Custom WindowFn implementations producing custom window kinds; experiments or SDKs with new window kinds not yet mapped in Go; misuse of coder constructors producing an invalid window kind.

Related errors


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/f6940dde1bfd7a68. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/graphx/coder.go:608

	for _, c := range list {
		if id, err := b.Add(c); err != nil {
			return nil, errors.Wrapf(err, "failed to marshal the coder %v.", c)
		} else {
			ids = append(ids, id)
		}
	}
	return ids, nil
}

// AddWindowCoder adds a window coder.
func (b *CoderMarshaller) AddWindowCoder(w *coder.WindowCoder) (string, error) {
	switch w.Kind {
	case coder.GlobalWindow:
		return b.internBuiltInCoder(urnGlobalWindow), nil
	case coder.IntervalWindow:
		return b.internBuiltInCoder(urnIntervalWindow), nil
	default:
		err := errors.Errorf("window coder with unexpected type %v", w.Kind)
		return "", errors.WithContextf(err, "failed to unmarshal window coder %v", w)
	}
}

// Build returns the set of model coders. Note that the map may be larger
// than the number of coders added, because component coders are included.
func (b *CoderMarshaller) Build() map[string]*pipepb.Coder {
	return b.coders
}

func (b *CoderMarshaller) internBuiltInCoder(urn string, components ...string) string {
	return b.internCoder(&pipepb.Coder{
		Spec: &pipepb.FunctionSpec{
			Urn: urn,
		},
		ComponentCoderIds: components,
	})
}

View on GitHub (pinned to 12126d8942)