{"record":{"id":"987b23d3cd108e1f","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-987b23","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 4 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 8 inputs and 4 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1869,"sourceCode":"}\n\nfunc (c *shimFunc8x4) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc8x4) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc8x4) Call8x4(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 any) (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], ret[3]\n}\n\nfunc ToFunc8x4(c Func) Func8x4 {\n\tif c.Type().NumIn() != 8 || c.Type().NumOut() != 4 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 4 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func8x4); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc8x4{inner: c}\n}\n\nfunc MakeFunc8x4(fn any) Func8x4 {\n\treturn ToFunc8x4(MakeFunc(fn))\n}\n","sourceCodeStart":1851,"sourceCodeEnd":1880,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1851-L1880","documentation":"reflectx.ToFunc8x4 converts a generic Func wrapper into a Func8x4 typed signature. The library panics because a function with 8 inputs and 4 outputs is required to build the typed shim; any other arity cannot be represented by Func8x4.","triggerScenarios":"Calling ToFunc8x4(c) where c.Type().NumIn() != 8 or c.Type().NumOut() != 4.","commonSituations":"Passing a function built with reflectx.NewFunc or reflect.MakeFunc whose signature was changed (inputs or outputs added/removed) without updating the ToFuncNxM variant used.","solutions":["Count the function's actual inputs and outputs and call the matching ToFunc variant (e.g. ToFunc8x3, ToFunc9x4).","Adjust the wrapped function's signature to exactly 8 parameters and 4 return values.","If the arity is dynamic, keep the generic Func instead of converting to a typed Func8x4."],"exampleFix":"// before\nf := reflectx.NewFunc(func(a int) int { return a })\nf8x4 := reflectx.ToFunc8x4(f) // panics\n// after\nf := reflectx.NewFunc(func(a,b,c,d,e,f2,g,h int) (int,int,int,int) { return a,b,c,d })\nf8x4 := reflectx.ToFunc8x4(f)","handlingStrategy":"validation","validationCode":"t := c.Type()\nif t.NumIn() != 8 || t.NumOut() != 4 {\n    panic(fmt.Sprintf(\"cannot convert to Func8x4: %d inputs, %d outputs\", t.NumIn(), t.NumOut()))\n}","typeGuard":"func isFunc8x4(v any) bool {\n    t := reflect.TypeOf(v)\n    return t != nil && t.Kind() == reflect.Func && t.NumIn() == 8 && t.NumOut() == 4\n}","tryCatchPattern":"func safeToFunc8x4(c reflectx.Func) (f reflectx.Func8x4, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"ToFunc8x4 failed: %v\", r)\n        }\n    }()\n    return reflectx.ToFunc8x4(c), nil\n}","preventionTips":["Match the function signature to the exact NxM variant before converting.","Count params and return values when refactoring wrapped functions."],"tags":["go","reflection","type-mismatch"],"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"}