{"record":{"id":"60988b71a85dd630","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-60988b","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 1 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 7 inputs and 1 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1541,"sourceCode":"}\n\nfunc (c *shimFunc7x1) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc7x1) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc7x1) Call7x1(arg0, arg1, arg2, arg3, arg4, arg5, arg6 any) any {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6})\n\t_ = ret\n\treturn ret[0]\n}\n\nfunc ToFunc7x1(c Func) Func7x1 {\n\tif c.Type().NumIn() != 7 || c.Type().NumOut() != 1 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 7 inputs and 1 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func7x1); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc7x1{inner: c}\n}\n\nfunc MakeFunc7x1(fn any) Func7x1 {\n\treturn ToFunc7x1(MakeFunc(fn))\n}\n\ntype Func7x2 interface {\n\tFunc\n\tCall7x2(any, any, any, any, any, any, any) (any, any)\n}\n\ntype shimFunc7x2 struct {\n\tinner Func","sourceCodeStart":1523,"sourceCodeEnd":1559,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1523-L1559","documentation":"reflectx.ToFunc7x1 converts a Func to a 7-input/1-output typed function and panics on any other arity. The generated shim indexes the return slice as ret[0], so it requires exactly one output. The panic message echoes the actual func type and its input/output counts.","triggerScenarios":"Calling ToFunc7x1 (or MakeFunc7x1) with a Func whose reflect.Type has inputs != 7 or outputs != 1, such as a 7-in/0-out sink or a 7-in/2-out function.","commonSituations":"Mapping functions that gained a second return value (value+error) without switching to ToFunc7x2; element-count changes in a DoFn's process signature; mismatched helper chosen in generated or copied registration code.","solutions":["Adjust the function to exactly 7 parameters and 1 return value","If it returns 0 or 2+ values, switch to the matching converter (ToFunc7x0, ToFunc7x2, ...)","If the input count is wrong, pick the converter for the true arity (e.g. ToFunc6x1)","Wrap conversion in a recover or pre-check NumIn/NumOut in plugin-style code"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g any) (any, error) { ... } // 2 outputs\nreflectx.ToFunc7x1(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g any) any { ... } // 1 output\nreflectx.ToFunc7x1(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 7 || t.NumOut() != 1 {\n    return fmt.Errorf(\"ToFunc7x1 needs 7 in / 1 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc7x1(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 7 && t.NumOut() == 1\n}","tryCatchPattern":"func safeToFunc7x1(f reflectx.Func) (fn reflectx.Func7x1, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc7x1(f)\n    return\n}","preventionTips":["One return value means Nx1; two (value+error) means Nx2 — pick accordingly","Count parameters carefully; ToFunc7x1 needs exactly 7","Let the compiler infer via MakeFunc7x1 on a typed function","Add construction-time tests for every registered function"],"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"}