apache/beam · error
Incompatible func type: got func
Error message
Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 0 outputs
What it means
reflectx.ToFunc8x0 adapts a Func as an 8-input/0-output (sink) function and panics if the wrapped signature differs. Any return values or a different input count trigger the panic because shimFunc8x0 performs a bare forwarding call. The message shows got vs want counts.
Solutions
- Make the function take exactly 8 parameters and return nothing
- If it returns values, use ToFunc8x1..ToFunc8xN as appropriate
- Use the correct input-count converter if 8 is wrong (e.g. ToFunc7x0)
- Catch or pre-check arity in dynamic registration paths
Example fix
// before
func(a, b, c, d, e, f2, g, h any) error { return nil } // 1 output
reflectx.ToFunc8x0(reflectx.NewFunc(fn)) // panics
// after
func(a, b, c, d, e, f2, g, h any) {} // 0 outputs
reflectx.ToFunc8x0(reflectx.NewFunc(fn)) // OK Defensive patterns
Strategy: validation
Validate before calling
t := f.Type()
if t.NumIn() != 8 || t.NumOut() != 0 {
return fmt.Errorf("ToFunc8x0 needs 8 in / 0 out, got %d in / %d out (%v)", t.NumIn(), t.NumOut(), t)
} Type guard
func isFunc8x0(f reflectx.Func) bool {
t := f.Type()
return t.NumIn() == 8 && t.NumOut() == 0
} Try / catch
func safeToFunc8x0(f reflectx.Func) (fn reflectx.Func8x0, err error) {
defer func() {
if r := recover(); r != nil {
err = fmt.Errorf("conversion failed: %v", r)
}
}()
fn = reflectx.ToFunc8x0(f)
return
} Prevention
- Sinks return nothing; use Nx1+ converters if an error return is needed
- Verify the 8-parameter signature after adding context/emitter args
- Prefer MakeFunc8x0 with a typed function
- Run a fast unit test that constructs the sink before launching pipelines
When it happens
Trigger: Calling ToFunc8x0 (or MakeFunc8x0) with a Func having inputs != 8 or any outputs (e.g. an 8-in/1-out function returning error).
Common situations: Sinks gaining an error return during refactors; an extra context/emitter parameter added or removed (7<->8 inputs) without swapping converters; reusing registration boilerplate from another stage.
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
- Incompatible func type: got func
- Incompatible func type: got func
- Incompatible func type: got func
- Incompatible func type: got func
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/d08955b41f9dce20.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/go/pkg/beam/core/util/reflectx/calls.go:1705
}
func (c *shimFunc8x0) Type() reflect.Type {
return c.inner.Type()
}
func (c *shimFunc8x0) Call(args []any) []any {
return c.inner.Call(args)
}
func (c *shimFunc8x0) Call8x0(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 any) {
ret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7})
_ = ret
return
}
func ToFunc8x0(c Func) Func8x0 {
if c.Type().NumIn() != 8 || c.Type().NumOut() != 0 {
panic(fmt.Sprintf("Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 0 outputs", c.Type(), c.Type().NumIn(), c.Type().NumOut()))
}
if sc, ok := c.(Func8x0); ok {
return sc
}
return &shimFunc8x0{inner: c}
}
func MakeFunc8x0(fn any) Func8x0 {
return ToFunc8x0(MakeFunc(fn))
}
type Func8x1 interface {
Func
Call8x1(any, any, any, any, any, any, any, any) any
}
type shimFunc8x1 struct {
inner FuncView on GitHub (pinned to 12126d8942)