{"record":{"id":"ffb1f002b07c6700","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-ffb1f0","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 2 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 8 inputs and 2 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1787,"sourceCode":"}\n\nfunc (c *shimFunc8x2) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc8x2) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc8x2) Call8x2(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 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]\n}\n\nfunc ToFunc8x2(c Func) Func8x2 {\n\tif c.Type().NumIn() != 8 || c.Type().NumOut() != 2 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 2 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func8x2); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc8x2{inner: c}\n}\n\nfunc MakeFunc8x2(fn any) Func8x2 {\n\treturn ToFunc8x2(MakeFunc(fn))\n}\n\ntype Func8x3 interface {\n\tFunc\n\tCall8x3(any, any, any, any, any, any, any, any) (any, any, any)\n}\n\ntype shimFunc8x3 struct {\n\tinner Func","sourceCodeStart":1769,"sourceCodeEnd":1805,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1769-L1805","documentation":"reflectx.ToFunc8x2 converts a Func to an 8-input/2-output typed function and panics if the arity differs. The shim returns ret[0], ret[1], which cannot represent any other output count. This is a deterministic construction-time panic for signature mismatches.","triggerScenarios":"Calling ToFunc8x2 (or MakeFunc8x2) with a Func of inputs != 8 or outputs != 2, e.g. an 8-in/1-out or 7-in/2-out function.","commonSituations":"Two-output DoFns refactored to return an error (1<->2 outputs) without re-picking the converter; adding/removing an input parameter (7<->8); generated-code arity drift between Beam SDK versions.","solutions":["Make the function take exactly 8 parameters and return exactly 2 values","Use the converter matching the true signature (ToFunc8x1, ToFunc7x2, etc.)","Update registrations after any signature refactor to the newly matching Func type","Pre-check c.Type().NumIn()/NumOut() where functions are chosen dynamically"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g any) (any, error) { ... } // 7 inputs\nreflectx.ToFunc8x2(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g, h any) (any, error) { ... } // 8 inputs, 2 outputs\nreflectx.ToFunc8x2(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 8 || t.NumOut() != 2 {\n    return fmt.Errorf(\"ToFunc8x2 needs 8 in / 2 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc8x2(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 8 && t.NumOut() == 2\n}","tryCatchPattern":"func safeToFunc8x2(f reflectx.Func) (fn reflectx.Func8x2, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc8x2(f)\n    return\n}","preventionTips":["(T, error) signatures are Nx2 — never register them with Nx1/Nx0 converters","Check input count (8) after refactors that add window/timestamp params","Prefer MakeFunc8x2 with a concrete Go function","Keep a table of registered signatures reviewed in code review"],"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"}