apache/beam · error

bad windowed value: %+v

Error message

bad windowed value: %+v

What it means

DecodeCoderRef converts windowed-value refs back into coders. The runner-side encoded form of a windowed value has exactly two components (the element coder and the window coder); any other count is malformed, so decoding fails with the ref printed.

Solutions

  1. Regenerate the pipeline artifact with the same SDK version used to decode it.
  2. Ensure graph-rewriting tools preserve both element and window components of windowed coders.
  3. Inspect the printed CoderRef: if it has one component, the producer SDK encodes windowed values differently — align versions.
  4. If hand-building CoderRefs for tests, include the window coder as the second component.

Example fix

// before
ref := &graphx.CoderRef{Type: graphx.WindowedValue, Components: []*graphx.CoderRef{elmRef}}
c, err := graphx.DecodeCoderRef(ref)

// after
ref := &graphx.CoderRef{Type: graphx.WindowedValue, Components: []*graphx.CoderRef{elmRef, windowRef}}
c, err := graphx.DecodeCoderRef(ref)
Defensive patterns

Strategy: try-catch

Validate before calling

func validWindowedRef(r *graphx.CoderRef) bool {
	return r != nil && r.Type == graphx.WindowedValue && len(r.Components) == 2
}

Type guard

func isWindowedRef(r *graphx.CoderRef) bool { return r != nil && r.Type == graphx.WindowedValue && len(r.Components) == 2 }

Try / catch

c, err := graphx.DecodeCoderRef(ref)
if err != nil {
	if strings.Contains(err.Error(), "bad windowed value") {
		return nil, fmt.Errorf("windowed ref needs element + window components %v: %w", ref, err)
	}
	return nil, err
}

Prevention

When it happens

Trigger: Decoding a CoderRef with Type windowedValueType whose Components has length != 2 — during pipeline deserialization where a windowed coder was encoded with a different shape (e.g. a version that omits or adds the window component).

Common situations: Cross-version pipelines (older SDKs encoded windowed values with one component); custom graph-rewriting tools that dropped the window component; hand-edited pipeline artifacts.

Related errors


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

Appendix: source

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

	case lengthPrefixType:
		if len(c.Components) != 1 {
			return nil, errors.Errorf("bad length prefix: %+v", c)
		}

		subC := c.Components[0]
		switch subC.Type {
		case stringType: // Needs special handling if wrapped by dataflow.
			return coder.NewString(), nil
		default:
			return decodeDataflowCustomCoder(subC.Type)
		}

	case intervalWindowType:
		return coder.NewIntervalWindowCoder(), nil

	case windowedValueType:
		if len(c.Components) != 2 {
			return nil, errors.Errorf("bad windowed value: %+v", c)
		}

		elm, err := DecodeCoderRef(c.Components[0])
		if err != nil {
			return nil, err
		}
		w, err := decodeWindowCoder(c.Components[1])
		if err != nil {
			return nil, err
		}
		t := typex.New(typex.WindowedValueType, elm.T)

		return &coder.Coder{Kind: coder.WindowedValue, T: t, Components: []*coder.Coder{elm}, Window: w}, nil

	case streamType:
		if len(c.Components) != 1 {
			return nil, errors.Errorf("bad iterable/stream: %+v", c)
		}

View on GitHub (pinned to 12126d8942)