{"record":{"id":"ad5943d4d526a747","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-ad5943","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 1 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 8 inputs and 1 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":1746,"sourceCode":"}\n\nfunc (c *shimFunc8x1) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc8x1) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc8x1) Call8x1(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 any) any {\n\tret := c.inner.Call([]any{arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7})\n\t_ = ret\n\treturn ret[0]\n}\n\nfunc ToFunc8x1(c Func) Func8x1 {\n\tif c.Type().NumIn() != 8 || c.Type().NumOut() != 1 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 8 inputs and 1 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func8x1); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc8x1{inner: c}\n}\n\nfunc MakeFunc8x1(fn any) Func8x1 {\n\treturn ToFunc8x1(MakeFunc(fn))\n}\n\ntype Func8x2 interface {\n\tFunc\n\tCall8x2(any, any, any, any, any, any, any, any) (any, any)\n}\n\ntype shimFunc8x2 struct {\n\tinner Func","sourceCodeStart":1728,"sourceCodeEnd":1764,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L1728-L1764","documentation":"reflectx.ToFunc8x1 wraps a Func as an 8-input/1-output function, panicking on any other arity. The shim returns ret[0], so exactly one output is required. The panic includes the offending reflect.Type and its input/output counts, firing before the pipeline runs.","triggerScenarios":"Calling ToFunc8x1 (or MakeFunc8x1) with a Func whose signature has inputs != 8 or outputs != 1, e.g. an 8-in/0-out sink or 8-in/2-out function.","commonSituations":"Mapping functions that dropped or added a return value; signature growth to 8 parameters after adding a timestamp/window arg while keeping an old converter; copied registrations targeting the wrong FuncNxM.","solutions":["Change the function to exactly 8 parameters and 1 return value","Switch to the converter matching actual arity (ToFunc8x0, ToFunc8x2, ...)","Correct the input count by choosing e.g. ToFunc7x1 if 8 is wrong","Validate NumIn/NumOut before conversion in generic code"],"exampleFix":"// before\nfunc(a, b, c, d, e, f2, g, h any) { ... } // 0 outputs\nreflectx.ToFunc8x1(reflectx.NewFunc(fn)) // panics\n// after\nfunc(a, b, c, d, e, f2, g, h any) any { ... } // 1 output\nreflectx.ToFunc8x1(reflectx.NewFunc(fn)) // OK","handlingStrategy":"validation","validationCode":"t := f.Type()\nif t.NumIn() != 8 || t.NumOut() != 1 {\n    return fmt.Errorf(\"ToFunc8x1 needs 8 in / 1 out, got %d in / %d out (%v)\", t.NumIn(), t.NumOut(), t)\n}","typeGuard":"func isFunc8x1(f reflectx.Func) bool {\n    t := f.Type()\n    return t.NumIn() == 8 && t.NumOut() == 1\n}","tryCatchPattern":"func safeToFunc8x1(f reflectx.Func) (fn reflectx.Func8x1, err error) {\n    defer func() {\n        if r := recover(); r != nil {\n            err = fmt.Errorf(\"conversion failed: %v\", r)\n        }\n    }()\n    fn = reflectx.ToFunc8x1(f)\n    return\n}","preventionTips":["Exactly one return value; drop it or move to Nx2 if error is added","Recount inputs whenever the process signature changes","Use MakeFunc8x1 for compile-time arity checking","Test converter calls outside the full pipeline run"],"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-20T03:17:13.778Z"}