{"record":{"id":"a8918fdd33ca1325","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-a8918f","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 3 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 6 inputs and 3 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1418,"sourceCode":"}\n\nfunc (c *shimFunc6x3) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc6x3) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc6x3) Call6x3(arg0, arg1, arg2, arg3, arg4, arg5 any) (any, any, any) {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5})\n\t_ = ret\n\treturn ret[0], ret[1], ret[2]\n}\n\nfunc ToFunc6x3(c Func) Func6x3 {\n\tif c.Type().NumIn() != 6 || c.Type().NumOut() != 3 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 6 inputs and 3 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func6x3); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc6x3{inner: c}\n}\n\nfunc MakeFunc6x3(fn any) Func6x3 {\n\treturn ToFunc6x3(MakeFunc(fn))\n}\n\ntype Func6x4 interface {\n\tFunc\n\tCall6x4(any, any, any, any, any, any) (any, any, any, any)\n}\n\ntype shimFunc6x4 struct {\n\tinner Func","sourceCodeStart":1400,"sourceCodeEnd":1436,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1400-L1436","documentation":"reflectx.ToFunc6x3 wraps a reflectx.Func into a Func6x3 (6 inputs, 3 outputs). It panics with this message unless the func's reflect.Type has exactly 6 inputs and 3 outputs, since the shim unpacks ret[0], ret[1], ret[2] positionally.","triggerScenarios":"Calling reflectx.ToFunc6x3(c) where c.Type().NumIn() != 6 or c.Type().NumOut() != 3 — e.g. a multi-output DoFn emitting 2 or 4 values, or one with the wrong input parameter count.","commonSituations":"Fan-out DoFns whose output tuple size drifted from the registered arity; mixing emit-style signatures with return-style ones; copy-paste of a registration line without updating the NxM helper.","solutions":["Align the function to exactly 6 inputs and 3 return values.","Use the ToFunc helper matching the actual arity (ToFunc6x2, ToFunc6x4, etc.).","Inspect the ProcessElement signature and the fixed-arity type used at registration; fix whichever is inconsistent."],"exampleFix":"// before\nfunc fn(a A, b B, c C, d D, e E, f F) (T, U) { ... }\nreflectx.ToFunc6x3(fn) // panics: 2 outputs\n\n// after\nfunc fn(a A, b B, c C, d D, e E, f F) (T, U, V) { ... }\nreflectx.ToFunc6x3(fn)","handlingStrategy":"validation","validationCode":"fn := reflect.TypeOf(fnAny)\nif fn.Kind() == reflect.Func && fn.NumIn() == 6 && fn.NumOut() == 3 {\n    _ = reflectx.ToFunc6x3(fnAny)\n}","typeGuard":"func isFunc6x3(f interface{}) bool {\n    t := reflect.TypeOf(f)\n    return t != nil && t.Kind() == reflect.Func && t.NumIn() == 6 && t.NumOut() == 3\n}","tryCatchPattern":"func safeToFunc6x3(c reflectx.Func) (f reflectx.Func6x3, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"ToFunc6x3 failed: %v\", r)\n        }\n    }()\n    return reflectx.ToFunc6x3(c), nil\n}","preventionTips":["For fan-out functions, keep emitted-value count and registered arity identical.","Prefer DoFn struct ProcessElement signatures over manual fixed-arity wrapping.","Run a pipeline-graph construction test locally to surface panics before submission.","Audit registration helper calls whenever any function's arity 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"}