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 6 inputs and 4 outputs
What it means
reflectx.ToFunc6x4 wraps an arbitrary reflectx Func as a strongly-typed 6-input/4-output function. It panics when the wrapped function's reflect.Type does not have exactly 6 inputs and 4 outputs, because the generated shim cannot adapt an arity mismatch. This library uses panics for programmer errors detected at pipeline-graph construction time.
Source
Thrown at sdks/go/pkg/beam/core/util/reflectx/calls.go:1459
}
func (c *shimFunc6x4) Type() reflect.Type {
return c.inner.Type()
}
func (c *shimFunc6x4) Call(args []any) []any {
return c.inner.Call(args)
}
func (c *shimFunc6x4) Call6x4(arg0, arg1, arg2, arg3, arg4, arg5 any) (any, any, any, any) {
ret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5})
_ = ret
return ret[0], ret[1], ret[2], ret[3]
}
func ToFunc6x4(c Func) Func6x4 {
if c.Type().NumIn() != 6 || c.Type().NumOut() != 4 {
panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 4 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut()))
}
if sc, ok := c.(Func6x4); ok {
return sc
}
return &shimFunc6x4{inner: c}
}
func MakeFunc6x4(fn any) Func6x4 {
return ToFunc6x4(MakeFunc(fn))
}
type Func7x0 interface {
Func
Call7x0(any, any, any, any, any, any, any)
}
type shimFunc7x0 struct {
inner FuncView on GitHub (pinned to 12126d8942)
Solutions
- Count the inputs and outputs of the function passed in and fix it to have exactly 6 parameters and 4 return values
- If the function intentionally has a different arity, call the matching ToFuncNxM converter (e.g. ToFunc7x4) instead
- If it should return fewer/more values, use a different FuncNxM target type or change the call site of the conversion
- Recover from the panic in tests to surface the message, since it prints got/want arity and the func type
Example fix
// before
f := reflectx.NewFunc(func(a, b, c, d, e any) (any, any, any) { ... })
fn := reflectx.ToFunc6x4(f) // panics: 5 inputs, 3 outputs
// after
f := reflectx.NewFunc(func(a, b, c, d, e, f2 any) (any, any, any, any) { ... })
fn := reflectx.ToFunc6x4(f) Defensive patterns
Strategy: validation
Validate before calling
t := f.Type()
if t.NumIn() != 6 || t.NumOut() != 4 {
return fmt.Errorf("ToFunc6x4 needs 6 in / 4 out, got %d in / %d out (%v)", t.NumIn(), t.NumOut(), t)
} Type guard
func isFunc6x4(f reflectx.Func) bool {
t := f.Type()
return t.NumIn() == 6 && t.NumOut() == 4
} Try / catch
func safeToFunc6x4(f reflectx.Func) (fn reflectx.Func6x4, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("conversion failed: %v", r)
}
}()
fn = reflectx.ToFunc6x4(f)
return
} Prevention
- Match converter choice to signature: NxM must equal the Go function's parameter and return counts
- Re-run arity checks after every signature refactor
- Prefer typed helpers (MakeFunc6x4 with a concrete Go func) so the compiler catches mismatches
- Cover converter calls in unit tests so panics surface early
When it happens
Trigger: Calling ToFunc6x4 (directly or via MakeFunc6x4) with a Func whose underlying Go signature has any number of inputs other than 6 or any number of outputs other than 4, e.g. wrapping a func(a,b,c,d,e any) (x,y,z any) (5 in, 3 out).
Common situations: DoFn methods or combinators registered with the wrong arity for the emitter/consumer being built; code changed from returning 3 values to 4 (e.g. adding an error) without updating the conversion; copy-paste of a ToFunc5x4-style registration where one parameter was forgotten; generics/type-parameter refactors changing the signature silently.
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/4012306d914ddcf1.
Report an issue: GitHub.