apache/beam · error

bad window kind

Error message

bad window kind: %v

What it means

encodeWindowCoder converts a beam WindowCoder into its wire CoderRef representation, but only GlobalWindows and IntervalWindows have defined encodings. Any other window kind (e.g. a session or custom window kind) has no Dataflow wire mapping, so encoding fails.

Solutions

  1. Restrict the pipeline to global windows or fixed/interval (sliding) windows supported by the target runner.
  2. Upgrade the SDK/runner to a version that supports the window kind in graphx encoding.
  3. Convert custom windowing to a supported windowing strategy before serialization.

Example fix

// before: custom window kind
pc := beam.WindowInto(s, myCustomWindowing, col)
// after
pc := beam.WindowInto(s, window.NewFixedWindows(60*time.Second), col)
Defensive patterns

Strategy: validation

Validate before calling

switch wc.Kind {
case coder.GlobalWindow, coder.IntervalWindow:
    // safe to encode
default:
    return errors.New("window kind not supported by runner")
}

Try / catch

if err != nil {
    if strings.Contains(err.Error(), "bad window kind") {
        // re-window the pipeline with fixed/global windows
    }
}

Prevention

When it happens

Trigger: Calling graphx.EncodeCoderRef or WrapWindowed with a WindowCoder whose Kind is neither GlobalWindow nor IntervalWindow.

Common situations: Using custom windowing in a pipeline submitted to a runner that only supports global/interval windows; window coder produced by a newer SDK with kinds this version cannot serialize.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


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

Appendix: source

Thrown at sdks/go/pkg/beam/core/runtime/graphx/dataflow.go:395

	}
	ref2 := ref.Components[0]
	if ref2.Type != cogbklistType {
		return nil, false
	}
	return ref2.Components, true
}

// encodeWindowCoder translates the preprocessed representation of a Beam coder
// into the wire representation, capturing the underlying types used by
// the coder.
func encodeWindowCoder(w *coder.WindowCoder) (*CoderRef, error) {
	switch w.Kind {
	case coder.GlobalWindow:
		return &CoderRef{Type: globalWindowType}, nil
	case coder.IntervalWindow:
		return &CoderRef{Type: intervalWindowType}, nil
	default:
		return nil, errors.Errorf("bad window kind: %v", w.Kind)
	}
}

// decodeWindowCoder receives the wire representation of a Beam coder, extracting
// the preprocessed representation, expanding all types used by the coder.
func decodeWindowCoder(w *CoderRef) (*coder.WindowCoder, error) {
	switch w.Type {
	case globalWindowType:
		return coder.NewGlobalWindow(), nil
	case intervalWindowType:
		return coder.NewIntervalWindow(), nil
	default:
		return nil, errors.Errorf("bad window: %v", w.Type)
	}
}

View on GitHub (pinned to 12126d8942)