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 0 outputs
What it means
reflectx.ToFunc7x0 adapts a Func into a 7-input/0-output (sink-style) function. It panics if the wrapped function does not have exactly 7 inputs and 0 outputs, since the shim can only forward arguments of matching arity. The panic fires at registration time, not at pipeline runtime.
Source
Thrown at sdks/go/pkg/beam/core/util/reflectx/calls.go:1500
}
func (c *shimFunc7x0) Type() reflect.Type {
return c.inner.Type()
}
func (c *shimFunc7x0) Call(args []any) []any {
return c.inner.Call(args)
}
func (c *shimFunc7x0) Call7x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) {
ret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6})
_ = ret
return
}
func ToFunc7x0(c Func) Func7x0 {
if c.Type().NumIn() != 7 || c.Type().NumOut() != 0 {
panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut()))
}
if sc, ok := c.(Func7x0); ok {
return sc
}
return &shimFunc7x0{inner: c}
}
func MakeFunc7x0(fn any) Func7x0 {
return ToFunc7x0(MakeFunc(fn))
}
type Func7x1 interface {
Func
Call7x1(any, any, any, any, any, any, any) any
}
type shimFunc7x1 struct {
inner FuncView on GitHub (pinned to 12126d8942)
Solutions
- Change the function to take exactly 7 parameters and return nothing
- If the function must return something, use the matching ToFunc7xN converter instead
- Use the correct arity converter (e.g. ToFunc6x0) if 7 inputs is wrong
- Guard conversions with an arity check before calling to convert the panic into a controlled error
Example fix
// before
func(a, b, c, d, e, f2, g any) error { return nil } // 7 in, 1 out
reflectx.ToFunc7x0(reflectx.NewFunc(fn)) // panics
// after
func(a, b, c, d, e, f2, g any) {} // 7 in, 0 out
reflectx.ToFunc7x0(reflectx.NewFunc(fn)) // OK Defensive patterns
Strategy: validation
Validate before calling
t := f.Type()
if t.NumIn() != 7 || t.NumOut() != 0 {
return fmt.Errorf("ToFunc7x0 needs 7 in / 0 out, got %d in / %d out (%v)", t.NumIn(), t.NumOut(), t)
} Type guard
func isFunc7x0(f reflectx.Func) bool {
t := f.Type()
return t.NumIn() == 7 && t.NumOut() == 0
} Try / catch
func safeToFunc7x0(f reflectx.Func) (fn reflectx.Func7x0, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("conversion failed: %v", r)
}
}()
fn = reflectx.ToFunc7x0(f)
return
} Prevention
- Sinks must return nothing; drop the error return or switch to a Nx1 converter
- Verify input count after adding context/emitter parameters
- Use MakeFunc7x0 with a directly typed function for compile-time safety
- Test converter calls at pipeline-construction time
When it happens
Trigger: Calling ToFunc7x0 (or MakeFunc7x0) with a Func whose signature has inputs != 7 or any return values at all (e.g. a 7-in/1-out function that returns an error).
Common situations: Sink/emit functions that were given an error return value during refactoring; passing a 6-input variant when a 7th context/collector parameter was required; reusing a helper built for another slot count.
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/995fd7d557907e14.
Report an issue: GitHub.