{"record":{"id":"5d36fee4273d89ff","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-5d36fe","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 2 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 7 inputs and 2 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1582,"sourceCode":"}\n\nfunc (c *shimFunc7x2) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc7x2) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc7x2) Call7x2(arg0, arg1, arg2, arg3, arg4, arg5, arg6 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]\n}\n\nfunc ToFunc7x2(c Func) Func7x2 {\n\tif c.Type().NumIn() != 7 || c.Type().NumOut() != 2 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 2 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func7x2); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc7x2{inner: c}\n}\n\nfunc MakeFunc7x2(fn any) Func7x2 {\n\treturn ToFunc7x2(MakeFunc(fn))\n}\n\ntype Func7x3 interface {\n\tFunc\n\tCall7x3(any, any, any, any, any, any, any) (any, any, any)\n}\n\ntype shimFunc7x3 struct {\n\tinner Func","sourceCodeStart":1564,"sourceCodeEnd":1600,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1564-L1600","documentation":"reflectx.ToFunc7x2 wraps a Func as a 7-input/2-output function and panics if the underlying signature does not match exactly. Shims like shimFunc7x2 unpack ret[0], ret[1], so any other output count cannot be supported. This is a construction-time programmer-error panic.","triggerScenarios":"Calling ToFunc7x2 (or MakeFunc7x2) with a Func having inputs != 7 or outputs != 2, e.g. a 7-in/1-out function or a 6-in/2-out function.","commonSituations":"Functions dropping the added error return (2->1 outputs) without changing the registration; DoFn signatures evolving to add a context param (6->7 inputs) while keeping the old converter; template-copied registration calls.","solutions":["Make the function take exactly 7 parameters and return exactly 2 values","Use the correct NxM converter matching the real signature (e.g. ToFunc7x1, ToFunc6x2)","Update call sites after signature refactors to the newly matching Func type","Pre-validate with c.Type().NumIn()/NumOut() before converting in dynamic code"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2 any) (any, error) { ... } // 6 inputs\nreflectx.ToFunc7x2(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g any) (any, error) { ... } // 7 inputs, 2 outputs\nreflectx.ToFunc7x2(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 7 || t.NumOut() != 2 {\n    return fmt.Errorf(\"ToFunc7x2 needs 7 in / 2 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc7x2(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 7 && t.NumOut() == 2\n}","tryCatchPattern":"func safeToFunc7x2(f reflectx.Func) (fn reflectx.Func7x2, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc7x2(f)\n    return\n}","preventionTips":["(T, error) return pairs map to Nx2 converters, not Nx1","Recheck arity after adding/removing input parameters","Use MakeFunc7x2 with a concretely typed function so mismatches fail at compile time","Keep converter choice and function signature in the same commit"],"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"}