{"record":{"id":"f71633d201becf19","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-f71633","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 1 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 6 inputs and 1 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1336,"sourceCode":"}\n\nfunc (c *shimFunc6x1) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc6x1) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc6x1) Call6x1(arg0, arg1, arg2, arg3, arg4, arg5 any) any {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5})\n\t_ = ret\n\treturn ret[0]\n}\n\nfunc ToFunc6x1(c Func) Func6x1 {\n\tif c.Type().NumIn() != 6 || c.Type().NumOut() != 1 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 1 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func6x1); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc6x1{inner: c}\n}\n\nfunc MakeFunc6x1(fn any) Func6x1 {\n\treturn ToFunc6x1(MakeFunc(fn))\n}\n\ntype Func6x2 interface {\n\tFunc\n\tCall6x2(any, any, any, any, any, any) (any, any)\n}\n\ntype shimFunc6x2 struct {\n\tinner Func","sourceCodeStart":1318,"sourceCodeEnd":1354,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1318-L1354","documentation":"reflectx.ToFunc6x1 wraps a reflectx.Func into a Func6x1 (6 inputs, 1 output). It panics with this message when the func's reflect.Type has any other arity, because the shim returns ret[0] directly and would index out of range otherwise.","triggerScenarios":"Calling reflectx.ToFunc6x1(c) where c.Type().NumIn() != 6 or c.Type().NumOut() != 1 — e.g. a 6-input function returning (T, error) or nothing.","commonSituations":"Map-style DoFns with 6 params returning 2 values; registration drift after adding a context/timestamp parameter; choosing the wrong ToFunc helper when converting to a fixed-arity type.","solutions":["Adjust the function to 6 inputs and exactly 1 return value.","Use ToFunc6x2 for a (T, error) style signature or ToFunc6x0 for void.","Cross-check the expected signature in the Beam registration and fix the mismatched side."],"exampleFix":"// before\nfunc fn(a A, b B, c C, d D, e E, f F) (T, error) { ... }\nreflectx.ToFunc6x1(fn) // panics: 2 outputs\n\n// after\nfunc fn(a A, b B, c C, d D, e E, f F) T { ... }\nreflectx.ToFunc6x1(fn)","handlingStrategy":"validation","validationCode":"fn := reflect.TypeOf(fnAny)\nif fn.Kind() == reflect.Func && fn.NumIn() == 6 && fn.NumOut() == 1 {\n    _ = reflectx.ToFunc6x1(fnAny)\n}","typeGuard":"func isFunc6x1(f interface{}) bool {\n    t := reflect.TypeOf(f)\n    return t != nil && t.Kind() == reflect.Func && t.NumIn() == 6 && t.NumOut() == 1\n}","tryCatchPattern":"func safeToFunc6x1(c reflectx.Func) (f reflectx.Func6x1, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"ToFunc6x1 failed: %v\", r)\n        }\n    }()\n    return reflectx.ToFunc6x1(c), nil\n}","preventionTips":["Treat (T, error) as 2 outputs; use the x2 helper or remove the error.","Verify parameter count after adding context or timestamp parameters.","Wrap-test all user functions in CI.","Match helper names to signatures during code review."],"tags":["go","apache-beam","reflection","function-signature"],"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"}