{"record":{"id":"33acd3a99c23ee05","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-33acd3","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 3 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 5 inputs and 3 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1213,"sourceCode":"}\n\nfunc (c *shimFunc5x3) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc5x3) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc5x3) Call5x3(arg0, arg1, arg2, arg3, arg4 any) (any, any, any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4})\n\t_ = ret\n\treturn ret[0], ret[1], ret[2]\n}\n\nfunc ToFunc5x3(c Func) Func5x3 {\n\tif c.Type().NumIn() != 5 || c.Type().NumOut() != 3 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 5 inputs and 3 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func5x3); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc5x3{inner: c}\n}\n\nfunc MakeFunc5x3(fn any) Func5x3 {\n\treturn ToFunc5x3(MakeFunc(fn))\n}\n\ntype Func5x4 interface {\n\tFunc\n\tCall5x4(any, any, any, any, any) (any, any, any, any)\n}\n\ntype shimFunc5x4 struct {\n\tinner Func","sourceCodeStart":1195,"sourceCodeEnd":1231,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1195-L1231","documentation":"reflectx.ToFunc5x3 wraps a reflectx.Func into a Func5x3 (5 inputs, 3 outputs). It panics with this message when the func's reflect.Type has any arity other than 5 inputs and 3 outputs. The shim needs the exact arity to return ret[0], ret[1], ret[2].","triggerScenarios":"Calling reflectx.ToFunc5x3(c) where c.Type().NumIn() != 5 or c.Type().NumOut() != 3 — e.g. a function emitting 2 or 4 values, or taking 4 or 6 inputs.","commonSituations":"DoFns emitting multiple outputs where the emitted-value count was changed (added/dropped a return) without updating the registration; mixing up (value..., error) conventions with pure multi-emission signatures.","solutions":["Align the function to exactly 5 inputs and 3 return values.","Use the ToFunc variant matching the real output count (ToFunc5x2, ToFunc5x4, etc.).","Audit the ProcessElement signature against the fixed-arity type used at registration time."],"exampleFix":"// before\nfunc fn(a A, b B, c C, d D, e E) (T, U) { ... }\nreflectx.ToFunc5x3(fn) // panics: 2 outputs\n\n// after\nfunc fn(a A, b B, c C, d D, e E) (T, U, V) { ... }\nreflectx.ToFunc5x3(fn)","handlingStrategy":"validation","validationCode":"fn := reflect.TypeOf(fnAny)\nif fn.Kind() == reflect.Func && fn.NumIn() == 5 && fn.NumOut() == 3 {\n    _ = reflectx.ToFunc5x3(fnAny)\n}","typeGuard":"func isFunc5x3(f interface{}) bool {\n    t := reflect.TypeOf(f)\n    return t != nil && t.Kind() == reflect.Func && t.NumIn() == 5 && t.NumOut() == 3\n}","tryCatchPattern":"func safeToFunc5x3(c reflectx.Func) (f reflectx.Func5x3, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"ToFunc5x3 failed: %v\", r)\n        }\n    }()\n    return reflectx.ToFunc5x3(c), nil\n}","preventionTips":["For multi-output functions, verify the emitted-value count matches the registered arity exactly.","Prefer generic registration APIs over fixed-arity helpers when signatures are in flux.","Add reflection-based assertions near DoFn definitions.","Review signature diffs in PRs for input/output count changes."],"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"}