apache/beam · error

unexpected composite inbound type

Error message

unexpected composite inbound type: %v

What it means

inboundArity computes how many bindings a composite inbound type needs; only KV (1) and CoGBK (component count) are supported. Any other composite type throws this error. It exists so the binder can determine the number of inbound edges a DoFn parameter consumes.

Solutions

  1. Use standard side input shapes: beam.KV (single iterator/map) or beam.CoGBK (multi component) types.
  2. Check t.Type() in the message and wrap/unwrap to KV or CoGBK before binding.
  3. Avoid manually constructing composite typex types for inputs; build via beam.AsMap/beam.AsIter helpers.
  4. Upgrade the SDK if a legitimately new composite type is in use and binder support is needed.

Example fix

// before: custom composite as side input
side := myCompositePColl
// after: standard map side input
side := beam.AsMap(s, kvPColl)
Defensive patterns

Strategy: validation

Validate before calling

// Go: only KV and CoGBK composites have defined inbound arity
tt := t.Type()
if t.Class() == typex.Composite && tt != typex.KVType && tt != typex.CoGBKType {
    return fmt.Errorf("composite %v unsupported for inbound arity", tt)
}

Prevention

When it happens

Trigger: Computing input arity for a side input or main input whose composite FullType is neither KV nor CoGBK — e.g. a Windowed-wrapped or custom composite used where arity must be derived.

Common situations: Custom side input types not produced by beam.KV/beam.CoGBK helpers; internal graph manipulation with unusual composite types; SDK version mismatch introducing new composite kinds.

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/886f4f89852b64cd. Report an issue: GitHub.

Appendix: source

Thrown at sdks/go/pkg/beam/core/graph/bind.go:327

	if !typex.IsStructurallyAssignable(t, other) {
		return nil, kind, errors.Errorf("%v is not assignable to %v", t, other)
	}
	return other, kind, nil
}

func inboundArity(t typex.FullType, isMain bool) (int, error) {
	if t.Class() == typex.Composite {
		switch t.Type() {
		case typex.KVType:
			if isMain {
				return 2, nil
			}
			// A KV side input must be a single iterator/map.
			return 1, nil
		case typex.CoGBKType:
			return len(t.Components()), nil
		default:
			return 0, errors.Errorf("unexpected composite inbound type: %v", t.Type())
		}
	}
	return 1, nil
}

func trimIllegal(list []reflect.Type) []reflect.Type {
	var ret []reflect.Type
	for _, elm := range list {
		switch typex.ClassOf(elm) {
		case typex.Concrete, typex.Universal, typex.Container:
			ret = append(ret, elm)
		}
	}
	return ret
}

View on GitHub (pinned to 12126d8942)