{"record":{"id":"41eef04a99a71a41","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-41eef0","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 3 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 7 inputs and 3 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1623,"sourceCode":"}\n\nfunc (c *shimFunc7x3) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc7x3) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc7x3) Call7x3(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) (any, any, any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6})\n\t_ = ret\n\treturn ret[0], ret[1], ret[2]\n}\n\nfunc ToFunc7x3(c Func) Func7x3 {\n\tif c.Type().NumIn() != 7 || c.Type().NumOut() != 3 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 3 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func7x3); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc7x3{inner: c}\n}\n\nfunc MakeFunc7x3(fn any) Func7x3 {\n\treturn ToFunc7x3(MakeFunc(fn))\n}\n\ntype Func7x4 interface {\n\tFunc\n\tCall7x4(any, any, any, any, any, any, any) (any, any, any, any)\n}\n\ntype shimFunc7x4 struct {\n\tinner Func","sourceCodeStart":1605,"sourceCodeEnd":1641,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1605-L1641","documentation":"reflectx.ToFunc7x3 adapts a Func to a strongly-typed 7-input/3-output function. It panics when the wrapped function's reflect.Type reports NumIn != 7 or NumOut != 3, because the shim returns exactly ret[0], ret[1], ret[2]. The panic names both got and want arity.","triggerScenarios":"Calling ToFunc7x3 (or MakeFunc7x3) with a Func of any other shape, e.g. a 7-in/2-out function or an 8-in/3-out function.","commonSituations":"Multi-output DoFns where an output (or an error return) was added/removed; moving a function between pipeline stages with different arity slots; off-by-one in generated Beam code selecting converters.","solutions":["Change the function to exactly 7 inputs and 3 outputs","Switch to the converter matching the actual arity (ToFunc7x2, ToFunc8x3, etc.)","Fix the intended registration target if the FuncNxM type was chosen wrong","Add a unit test asserting the converted type before building the pipeline"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g any) (any, any) { ... } // 2 outputs\nreflectx.ToFunc7x3(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g any) (any, any, any) { ... } // 3 outputs\nreflectx.ToFunc7x3(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 7 || t.NumOut() != 3 {\n    return fmt.Errorf(\"ToFunc7x3 needs 7 in / 3 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc7x3(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 7 && t.NumOut() == 3\n}","tryCatchPattern":"func safeToFunc7x3(f reflectx.Func) (fn reflectx.Func7x3, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc7x3(f)\n    return\n}","preventionTips":["Multi-output functions: every output (including error) counts toward NumOut","Confirm 7 inputs after any DoFn signature change","Prefer MakeFunc7x3 over generic Func + ToFunc7x3 when possible","Assert converted arity in pipeline-building tests"],"tags":["go","apache-beam","reflection","function-arity","panic"],"backgroundTag":"type-mismatch","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}