apache/beam · error

is not assignable to

Error message

%v is not assignable to %v

What it means

After building the expected type 'other' from the parameter components, tryBindInbound checks typex.IsStructurallyAssignable(t, other). This error means the actual inbound type is not structurally assignable to the type expected by the function's parameter — the shapes (single vs composite, KV vs pair) do not line up. It is Beam's way of reporting a DoFn signature that does not match its input PCollection.

Solutions

  1. Align the DoFn signature with the input type: KV input requires func(k K, v V ...) or func(kv beam.KV ...); single value requires func(v T ...).
  2. Insert a transform to reshape data (beam.KV construction/beam.ExtractKey) so types match.
  3. Read both %v values in the message: first is your actual input type, second is what the function expects.
  4. Use beam.TryIsStructurallyAssignable or a small unit test with graph binding to verify signatures early.

Example fix

// before: func(kv T) against a KV input
func myDo(kv MyType) { ... }
// after: match KV shape
func myDo(k string, v int) { ... }
Defensive patterns

Strategy: validation

Validate before calling

// Go: check structural assignability before wiring a DoFn
if !typex.IsStructurallyAssignable(inType, expectedType) {
    return fmt.Errorf("input %v does not match DoFn signature %v", inType, expectedType)
}

Prevention

When it happens

Trigger: Binding a PCollection<T> to a DoFn that declares KV<K,V> parameters, or a KV input to a function expecting a single value; also side inputs whose type differs from the side-input signature.

Common situations: Refactoring a DoFn from single-value to KV without updating the input PCollection; beam.ParDo on a CoGBK output with the wrong signature; mismatched side input types in beam.SideInput.

Understand the failure class

Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.

Related errors


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

Appendix: source

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

						return nil, kind, errors.Errorf("values of %v cannot bind to %v", t, args[i])
					}
					components = append(components, typex.New(trimmed[0]))
				default:
					return nil, kind, errors.Errorf("values of %v cannot bind to %v", t, args[i])
				}
			}
			other = typex.NewCoGBK(components...)

		default:
			return nil, kind, errors.Errorf("unexpected inbound type: %v", t.Type())
		}

	default:
		return nil, kind, errors.Errorf("unexpected inbound class: %v", t.Class())
	}

	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())
		}

View on GitHub (pinned to 12126d8942)