apache/beam · error
Incompatible func type: got func %v with %v inputs and %v ou
Error message
Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 4 outputs
What it means
reflectx.ToFunc7x4 converts a Func into a 7-input/4-output typed function and panics on any arity mismatch. The shim returns ret[0]..ret[3], so exactly 4 outputs and 7 inputs are mandatory. This surfaces at graph-construction time as a panic with the offending func type in the message.
Source
Thrown at sdks/go/pkg/beam/core/util/reflectx/calls.go:1664
}
func (c *shimFunc7x4) Type() reflect.Type {
return c.inner.Type()
}
func (c *shimFunc7x4) Call(args []any) []any {
return c.inner.Call(args)
}
func (c *shimFunc7x4) Call7x4(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) (any, any, any, any) {
ret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6})
_ = ret
return ret[0], ret[1], ret[2], ret[3]
}
func ToFunc7x4(c Func) Func7x4 {
if c.Type().NumIn() != 7 || c.Type().NumOut() != 4 {
panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 4 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut()))
}
if sc, ok := c.(Func7x4); ok {
return sc
}
return &shimFunc7x4{inner: c}
}
func MakeFunc7x4(fn any) Func7x4 {
return ToFunc7x4(MakeFunc(fn))
}
type Func8x0 interface {
Func
Call8x0(any, any, any, any, any, any, any, any)
}
type shimFunc8x0 struct {
inner FuncView on GitHub (pinned to 12126d8942)
Solutions
- Adjust the function to exactly 7 parameters and 4 return values
- Use the matching ToFuncNxM for the real signature (e.g. ToFunc7x3, ToFunc8x4)
- Align the converter choice with the pipeline stage's expected outputs
- Check NumIn/NumOut before converting in generic/plugin code
Example fix
// before
func(a, b, c, d, e, f2, g any) (any, any, any) { ... } // 3 outputs
reflectx.ToFunc7x4(reflectx.NewFunc(fn)) // panics
// after
func(a, b, c, d, e, f2, g any) (any, any, any, any) { ... } // 4 outputs
reflectx.ToFunc7x4(reflectx.NewFunc(fn)) // OK Defensive patterns
Strategy: validation
Validate before calling
t := f.Type()
if t.NumIn() != 7 || t.NumOut() != 4 {
return fmt.Errorf("ToFunc7x4 needs 7 in / 4 out, got %d in / %d out (%v)", t.NumIn(), t.NumOut(), t)
} Type guard
func isFunc7x4(f reflectx.Func) bool {
t := f.Type()
return t.NumIn() == 7 && t.NumOut() == 4
} Try / catch
func safeToFunc7x4(f reflectx.Func) (fn reflectx.Func7x4, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("conversion failed: %v", r)
}
}()
fn = reflectx.ToFunc7x4(f)
return
} Prevention
- Four outputs required — include every emitted collection plus error in the count
- Update the converter alongside any 3->4 output refactor
- Use typed MakeFunc7x4 for compile-time checks
- Gate registrations behind construction-time smoke tests
When it happens
Trigger: Calling ToFunc7x4 (or MakeFunc7x4) with a Func whose signature has inputs != 7 or outputs != 4, e.g. a 7-in/3-out or 8-in/4-out function.
Common situations: Beam DoFns emitting multiple collections where one output was added (3->4) without updating the wrapper; arity drift after API refactors; mistakenly passing the raw Go func without the matching NewFunc/Func type.
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
- Incompatible func type: got func %v with %v inputs and %v ou
- Incompatible func type: got func %v with %v inputs and %v ou
- Incompatible func type: got func %v with %v inputs and %v ou
- Incompatible func type: got func %v with %v inputs and %v ou
- Incompatible func type: got func %v with %v inputs and %v ou
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/e5e0083596655229.
Report an issue: GitHub.