{"record":{"id":"aba6f36ad7a72bd5","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-aba6f3","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 3 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 8 inputs and 3 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1828,"sourceCode":"}\n\nfunc (c *shimFunc8x3) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc8x3) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc8x3) Call8x3(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 any) (any, any, any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7})\n\t_ = ret\n\treturn ret[0], ret[1], ret[2]\n}\n\nfunc ToFunc8x3(c Func) Func8x3 {\n\tif c.Type().NumIn() != 8 || c.Type().NumOut() != 3 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 3 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func8x3); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc8x3{inner: c}\n}\n\nfunc MakeFunc8x3(fn any) Func8x3 {\n\treturn ToFunc8x3(MakeFunc(fn))\n}\n\ntype Func8x4 interface {\n\tFunc\n\tCall8x4(any, any, any, any, any, any, any, any) (any, any, any, any)\n}\n\ntype shimFunc8x4 struct {\n\tinner Func","sourceCodeStart":1810,"sourceCodeEnd":1846,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1810-L1846","documentation":"reflectx.ToFunc8x3 adapts a Func into an 8-input/3-output function and panics when NumIn != 8 or NumOut != 3, since the shim returns exactly ret[0], ret[1], ret[2]. The panic message states the got and want arity plus the offending func type. It fires at pipeline-construction time.","triggerScenarios":"Calling ToFunc8x3 (or MakeFunc8x3) with a Func whose signature has any other shape, e.g. an 8-in/2-out function or a 9-in/3-out function.","commonSituations":"Three-output DoFns where an output or error return was added/removed; extra emitter parameter added (7<->8 inputs) without updating the conversion; wrong slot chosen in hand-written or generated registration code.","solutions":["Adjust the function to exactly 8 inputs and 3 outputs","Pick the converter matching the real arity (ToFunc8x2, ToFunc7x3, etc.)","Fix the target FuncNxM type at the registration call site","Add an arity assertion/test before building the pipeline"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g, h any) (any, any) { ... } // 2 outputs\nreflectx.ToFunc8x3(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g, h any) (any, any, any) { ... } // 3 outputs\nreflectx.ToFunc8x3(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 8 || t.NumOut() != 3 {\n    return fmt.Errorf(\"ToFunc8x3 needs 8 in / 3 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc8x3(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 8 && t.NumOut() == 3\n}","tryCatchPattern":"func safeToFunc8x3(f reflectx.Func) (fn reflectx.Func8x3, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc8x3(f)\n    return\n}","preventionTips":["Count all three outputs (values and error) when choosing NxM","Re-verify the 8-input signature after emitter additions","Use MakeFunc8x3 so the compiler enforces arity","Cover every registration in a construction-time test suite"],"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-20T03:17:13.778Z"}