apache/beam · error

failed getGroup for %v: %v

Error message

failed getGroup for %v: %v

What it means

In the direct runner's CoGBK ProcessElement, for each incoming window the node calls getGroup to create/look up the accumulation group for the key+window. If getGroup fails (e.g. inability to compute the window/key representation), the unit returns this error embedding the element and the cause, aborting the bundle.

Source

Thrown at sdks/go/pkg/beam/runners/direct/gbk.go:73

	n.m = make(map[string]*group)
	return nil
}

func (n *CoGBK) StartBundle(ctx context.Context, id string, data exec.DataContext) error {
	return n.Out.StartBundle(ctx, id, data)
}

func (n *CoGBK) ProcessElement(ctx context.Context, elm *exec.FullValue, _ ...exec.ReStream) error {
	index := elm.Elm2.(*exec.FullValue).Elm.(int)
	value := elm.Elm2.(*exec.FullValue).Elm2

	for _, w := range elm.Windows {
		ws := []typex.Window{w}
		n.wins = append(n.wins, ws...)

		g, err := n.getGroup(n.m, elm, ws)
		if err != nil {
			return errors.Errorf("failed getGroup for %v: %v", elm, err)
		}
		g.values[index] = append(g.values[index], exec.FullValue{Elm: value, Timestamp: elm.Timestamp})
	}
	return nil
}

func (n *CoGBK) getGroup(m map[string]*group, elm *exec.FullValue, ws []typex.Window) (*group, error) {
	var buf bytes.Buffer
	if err := n.enc.Encode(&exec.FullValue{Elm: elm.Elm}, &buf); err != nil {
		return nil, errors.WithContextf(err, "encoding key %v for CoGBK", elm)
	}
	if err := n.wEnc.Encode(ws, &buf); err != nil {
		return nil, errors.WithContextf(err, "encoding window %v for CoGBK", ws)
	}
	key := buf.String()
	g, ok := m[key]
	if !ok {
		g = &group{

View on GitHub (pinned to 12126d8942)

Solutions

  1. Read the embedded cause (%v, err) — it names why getGroup failed for that element.
  2. Verify the pipeline's windowing strategy is one the direct runner supports (fixed/interval/sessions), and that elements have valid windows.
  3. Simplify custom WindowFn implementations or test them with window tests before running.
  4. Reproduce with a minimal dataset to find the specific element whose windows trigger the failure.

Example fix

// before
beam.WindowInto(s, window.NewCustomWindowing(weirdFn), col) // unsupported in CoGBK
// after
beam.WindowInto(s, window.NewFixedWindows(10*time.Minute), col)
Defensive patterns

Strategy: try-catch

Try / catch

err := plan.Execute(ctx, "", exec.DataContext{})
if err != nil && strings.Contains(err.Error(), "failed getGroup") {
    log.Printf("CoGBK grouping failed on an element/window; inspect windows: %v", err)
}

Prevention

When it happens

Trigger: Processing an element in a CoGBK node where n.getGroup(n.m, elm, ws) errors — typically due to an unexpected window type or a failure encoding the key for grouping within the runner's in-memory map.

Common situations: Custom windowing strategies the direct runner's CoGBK doesn't handle; elements carrying malformed or zero windows after a WindowInto; pipelines mixing window merging semantics across inputs.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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