{"record":{"id":"fe9603039eaa23b1","repo":"apache/beam","slug":"v-cannot-bind-to-v","errorCode":null,"errorMessage":"%v cannot bind to %v","messagePattern":"(.+?) cannot bind to (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/bind.go","lineNumber":201,"sourceCode":"\t\t\t// string by matching up the incoming type and the param type.\n\n\t\t\targ := args[0]\n\t\t\tswitch arg.Kind {\n\t\t\tcase funcx.FnValue:\n\t\t\t\tif args[0].T.Kind() == reflect.Slice && t.Type() == args[0].T.Elem() {\n\t\t\t\t\t// TODO(herohde) 6/29/2017: we do not allow universal slices, for now.\n\n\t\t\t\t\tkind = Slice\n\t\t\t\t\tother = typex.New(args[0].T.Elem())\n\t\t\t\t} else {\n\t\t\t\t\tkind = Singleton\n\t\t\t\t\tother = typex.New(args[0].T)\n\t\t\t\t}\n\t\t\tcase funcx.FnIter:\n\t\t\t\tvalues, _ := funcx.UnfoldIter(args[0].T)\n\t\t\t\ttrimmed := trimIllegal(values)\n\t\t\t\tif len(trimmed) != 1 {\n\t\t\t\t\treturn nil, kind, errors.Errorf(\"%v cannot bind to %v\", t, args[0])\n\t\t\t\t}\n\n\t\t\t\tkind = Iter\n\t\t\t\tother = typex.New(trimmed[0])\n\n\t\t\tcase funcx.FnReIter:\n\t\t\t\tvalues, _ := funcx.UnfoldReIter(args[0].T)\n\t\t\t\ttrimmed := trimIllegal(values)\n\t\t\t\tif len(trimmed) != 1 {\n\t\t\t\t\treturn nil, kind, errors.Errorf(\"%v cannot bind to %v\", t, args[0])\n\t\t\t\t}\n\n\t\t\t\tkind = ReIter\n\t\t\t\tother = typex.New(trimmed[0])\n\n\t\t\tcase funcx.FnMultiMap:\n\t\t\t\treturn nil, kind, errors.Errorf(\"input to MultiMap side input must be KV, got %v\", t)\n","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/bind.go#L183-L219","documentation":"tryBindInbound matches a requested parameter kind (here an Iter function) against the actual inbound type available from the input PCollection. When an Iter<T> parameter is used but unpacking the input type does not yield exactly one element type, the bind fails with '%v cannot bind to %v', indicating the function parameter type cannot consume the input the pipeline provides.","triggerScenarios":"Using a func(func(T) bool) (iterator) parameter while the input PCollection is empty, a KV, or a coder whose UnfoldIter does not produce exactly one element type; feeding a KV stream into a function expecting a plain iter.","commonSituations":"ParDo on a KV output where the DoFn declares a single-value iterator; mismatched side-input types; pipeline shape changed upstream (e.g. a beam.ParDo after beam.KV-producing transform) without updating the DoFn signature.","solutions":["Change the parameter to match the input shape, e.g. accept KV via func(K, func(V) bool) or a KV-typed value.","Restructure the pipeline so the input to this DoFn is a plain single-element PCollection.","Print the input PCollection's type (pcoll.Type()) and align the DoFn's inbound parameter with it."],"exampleFix":"// before\nfunc (f *fn) ProcessElement(it func(int) bool) { ... } // input is KV<string,int>\n// after\nfunc (f *fn) ProcessElement(k string, v int) { ... }","handlingStrategy":"validation","validationCode":"values, _ := funcx.UnfoldIter(inputType)\nif len(funcx.TrimIllegal(values)) != 1 {\n    return fmt.Errorf(\"input %v cannot feed an Iter parameter\", inputType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Inspect pcoll.ElementType() before writing the DoFn signature.","Match KV inputs with KV-style parameters, not plain iterators.","Re-check DoFn signatures whenever upstream transforms change output shapes."],"tags":["go","beam","type-binding","pardo"],"backgroundTag":"incompatible-source-type","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}