{"record":{"id":"946412ab364463ba","repo":"apache/beam","slug":"incompatible-func-type-got-func-v-with-v-inputs-and-v-946412","errorCode":null,"errorMessage":"Incompatible func type: got func %v with %v inputs and %v outputs, want 1 inputs and 0 outputs","messagePattern":"Incompatible func type: got func (.+?) with (.+?) inputs and (.+?) outputs, want 1 inputs and 0 outputs","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/util/reflectx/calls.go","lineNumber":270,"sourceCode":"}\n\nfunc (c *shimFunc1x0) Type() reflect.Type {\n\treturn c.inner.Type()\n}\n\nfunc (c *shimFunc1x0) Call(args []any) []any {\n\treturn c.inner.Call(args)\n}\n\nfunc (c *shimFunc1x0) Call1x0(arg0 any) {\n\tret := c.inner.Call([]any{arg0})\n\t_ = ret\n\treturn\n}\n\nfunc ToFunc1x0(c Func) Func1x0 {\n\tif c.Type().NumIn() != 1 || c.Type().NumOut() != 0 {\n\t\tpanic(fmt.Sprintf(\"Incompatible func type: got func %v with %v inputs and %v outputs, want 1 inputs and 0 outputs\", c.Type(), c.Type().NumIn(), c.Type().NumOut()))\n\t}\n\tif sc, ok := c.(Func1x0); ok {\n\t\treturn sc\n\t}\n\treturn &shimFunc1x0{inner: c}\n}\n\nfunc MakeFunc1x0(fn any) Func1x0 {\n\treturn ToFunc1x0(MakeFunc(fn))\n}\n\ntype Func1x1 interface {\n\tFunc\n\tCall1x1(any) any\n}\n\ntype shimFunc1x1 struct {\n\tinner Func","sourceCodeStart":252,"sourceCodeEnd":288,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/util/reflectx/calls.go#L252-L288","documentation":"ToFunc1x0 adapts a generic reflectx Func into a Func1x0 (1 input, 0 outputs, i.e. a consumer). It panics when the wrapped function's type does not have exactly 1 input and 0 outputs. The check exists so signature mismatches surface immediately at adaptation time.","triggerScenarios":"Calling reflectx.ToFunc1x0 or MakeFunc1x0 with a Func whose Type().NumIn() != 1 or Type().NumOut() != 0, e.g. a function returning a value or an error, or taking 2+ parameters.","commonSituations":"Wrapping a process-element function that returns an error; passing a function that accidentally kept a return statement after a refactor; using the wrong MakeFuncNxM helper after changing a sink's signature.","solutions":["Make the wrapped function take exactly 1 input and return nothing.","Switch to the ToFunc/MakeFunc variant that matches the real arity (e.g. ToFunc1x1 if it returns one value).","Inspect c.Type().NumIn()/NumOut() at the call site to pick the right helper."],"exampleFix":"// before\nreflectx.MakeFunc1x0(func(x int) error { return nil }) // panics: 1 output\n// after\nreflectx.MakeFunc1x0(func(x int) { _ = x })","handlingStrategy":"validation","validationCode":"t := c.Type()\nif t.NumIn() != 1 || t.NumOut() != 0 {\n    return fmt.Errorf(\"func %v has %d ins/%d outs; ToFunc1x0 needs 1 in/0 outs\", t, t.NumIn(), t.NumOut())\n}","typeGuard":"func isFunc1x0(c reflectx.Func) bool {\n    return c.Type().NumIn() == 1 && c.Type().NumOut() == 0\n}","tryCatchPattern":"func safeToFunc1x0(c reflectx.Func) (f reflectx.Func1x0) {\n    defer func() {\n        if r := recover(); r != nil {\n            log.Fatalf(\"ToFunc1x0 arity mismatch: %v\", r)\n        }\n    }()\n    return reflectx.ToFunc1x0(c)\n}","preventionTips":["Remove stray return values from sink/consumer functions before wrapping.","Match each function literal to exactly one MakeFuncNxM helper and keep them adjacent in code.","Grep for MakeFunc1x0 call sites whenever a wrapped function's signature changes."],"tags":["go","reflection","arity-mismatch","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"}