{"record":{"id":"0c5ad108b7b1153e","repo":"apache/beam","slug":"values-of-v-cannot-bind-to-v","errorCode":null,"errorMessage":"values of %v cannot bind to %v","messagePattern":"values of (.+?) cannot bind to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/bind.go","lineNumber":284,"sourceCode":"\t\t\t\tdefault:\n\t\t\t\t\treturn nil, kind, errors.Errorf(\"%v cannot bind to %v\", t, args[0])\n\t\t\t\t}\n\t\t\t}\n\n\t\tcase typex.CoGBKType:\n\t\t\tif args[0].Kind != funcx.FnValue {\n\t\t\t\treturn nil, kind, errors.Errorf(\"key of %v cannot bind to %v\", t, args[0])\n\t\t\t}\n\n\t\t\tcomponents := []typex.FullType{typex.New(args[0].T)}\n\n\t\t\tfor i := 1; i < len(args); i++ {\n\t\t\t\tswitch args[i].Kind {\n\t\t\t\tcase funcx.FnIter:\n\t\t\t\t\tvalues, _ := funcx.UnfoldIter(args[i].T)\n\t\t\t\t\ttrimmed := trimIllegal(values)\n\t\t\t\t\tif len(trimmed) != 1 {\n\t\t\t\t\t\treturn nil, kind, errors.Errorf(\"values of %v cannot bind to %v\", t, args[i])\n\t\t\t\t\t}\n\t\t\t\t\tcomponents = append(components, typex.New(trimmed[0]))\n\n\t\t\t\tcase funcx.FnReIter:\n\t\t\t\t\tvalues, _ := funcx.UnfoldReIter(args[i].T)\n\t\t\t\t\ttrimmed := trimIllegal(values)\n\t\t\t\t\tif len(trimmed) != 1 {\n\t\t\t\t\t\treturn nil, kind, errors.Errorf(\"values of %v cannot bind to %v\", t, args[i])\n\t\t\t\t\t}\n\t\t\t\t\tcomponents = append(components, typex.New(trimmed[0]))\n\t\t\t\tdefault:\n\t\t\t\t\treturn nil, kind, errors.Errorf(\"values of %v cannot bind to %v\", t, args[i])\n\t\t\t\t}\n\t\t\t}\n\t\t\tother = typex.NewCoGBK(components...)\n\n\t\tdefault:\n\t\t\treturn nil, kind, errors.Errorf(\"unexpected inbound type: %v\", t.Type())","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/bind.go#L266-L302","documentation":"Apache Beam (Go) throws this while binding the value-iterator parameters of a CoGBK side input: each parameter after the key must be an FnIter (or FnReIter) whose element unfolds to exactly 1 legal component after trimIllegal. If the iterator's element type is itself a composite whose components get trimmed to 0 or 2+ entries, the iterator cannot represent a single CoGBK value stream and binding fails.","triggerScenarios":"A CoGBK side-input function whose value parameter is func(i *func.Iter) bool where the iterated element is a KV or other multi-component composite (UnfoldIter + trimIllegal yields len != 1); also fires when the parameter kind is FnMultiMap or another unsupported kind (default branch, same message).","commonSituations":"Iterating KV pairs in a CoGBK value parameter (should iterate plain values; the key is already a separate parameter); passing a MultiMap parameter where per-input Iter parameters are expected; nesting KVs inside CoGBK values so trimIllegal strips/miscounts components.","solutions":["Make each value parameter iterate exactly the plain value type, not a KV: func(k K, v1 func(*func.Iter) bool, v2 func(*func.Iter) bool) bool","Extract values from nested KVs (beam.ExtractKV / restructure the pipeline) so the iterator yields a single concrete component","Use a MultiMap parameter only for the CoGBK-as-map access pattern, not mixed with per-input Iter parameters","Check that CoGBK inputs are PCollections of plain values, not KVs, unless you intend the KV as the value component"],"exampleFix":"// before\nfunc(k string, kv func(*func.Iter) bool) bool { /* iterates KV<K2,V2> */ }\n// after\nfunc(k string, v func(*func.Iter) bool) bool { /* iterates plain V */ }","handlingStrategy":"validation","validationCode":"// Each CoGBK value parameter must iterate a single concrete component\n// el := reflect.TypeOf(iterElem) ; require typex.ClassOf(el) in {Concrete, Universal, Container}","typeGuard":"func iterElemIsSingleComponent(fn interface{}, idx int) bool {\n\tt := reflect.TypeOf(fn)\n\tif t == nil || idx >= t.NumIn() {\n\t\treturn false\n\t}\n\tp := t.In(idx)\n\treturn p.Kind() == reflect.Func && p.NumIn() == 1 && p.In(0).Kind() == reflect.Ptr\n}","tryCatchPattern":null,"preventionTips":["Iterate plain values, not KVs, in CoGBK value parameters — the key arrives as its own parameter","Flatten nested composites in CoGBK value PCollections before binding","Use MultiMap only for the whole-CoGBK-as-map pattern, never mixed with per-input Iter parameters"],"tags":["go","apache-beam","cogbk","side-input","type-mismatch"],"backgroundTag":"type-mismatch","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"}