{"record":{"id":"a3cc1ced52c3faf2","repo":"apache/beam","slug":"v-is-not-assignable-to-v","errorCode":null,"errorMessage":"%v is not assignable to %v","messagePattern":"(.+?) is not assignable to (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/graph/bind.go","lineNumber":310,"sourceCode":"\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())\n\t\t}\n\n\tdefault:\n\t\treturn nil, kind, errors.Errorf(\"unexpected inbound class: %v\", t.Class())\n\t}\n\n\tif !typex.IsStructurallyAssignable(t, other) {\n\t\treturn nil, kind, errors.Errorf(\"%v is not assignable to %v\", t, other)\n\t}\n\treturn other, kind, nil\n}\n\nfunc inboundArity(t typex.FullType, isMain bool) (int, error) {\n\tif t.Class() == typex.Composite {\n\t\tswitch t.Type() {\n\t\tcase typex.KVType:\n\t\t\tif isMain {\n\t\t\t\treturn 2, nil\n\t\t\t}\n\t\t\t// A KV side input must be a single iterator/map.\n\t\t\treturn 1, nil\n\t\tcase typex.CoGBKType:\n\t\t\treturn len(t.Components()), nil\n\t\tdefault:\n\t\t\treturn 0, errors.Errorf(\"unexpected composite inbound type: %v\", t.Type())\n\t\t}","sourceCodeStart":292,"sourceCodeEnd":328,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/graph/bind.go#L292-L328","documentation":"After building the expected type 'other' from the parameter components, tryBindInbound checks typex.IsStructurallyAssignable(t, other). This error means the actual inbound type is not structurally assignable to the type expected by the function's parameter — the shapes (single vs composite, KV vs pair) do not line up. It is Beam's way of reporting a DoFn signature that does not match its input PCollection.","triggerScenarios":"Binding a PCollection<T> to a DoFn that declares KV<K,V> parameters, or a KV input to a function expecting a single value; also side inputs whose type differs from the side-input signature.","commonSituations":"Refactoring a DoFn from single-value to KV without updating the input PCollection; beam.ParDo on a CoGBK output with the wrong signature; mismatched side input types in beam.SideInput.","solutions":["Align the DoFn signature with the input type: KV input requires func(k K, v V ...) or func(kv beam.KV ...); single value requires func(v T ...).","Insert a transform to reshape data (beam.KV construction/beam.ExtractKey) so types match.","Read both %v values in the message: first is your actual input type, second is what the function expects.","Use beam.TryIsStructurallyAssignable or a small unit test with graph binding to verify signatures early."],"exampleFix":"// before: func(kv T) against a KV input\nfunc myDo(kv MyType) { ... }\n// after: match KV shape\nfunc myDo(k string, v int) { ... }","handlingStrategy":"validation","validationCode":"// Go: check structural assignability before wiring a DoFn\nif !typex.IsStructurallyAssignable(inType, expectedType) {\n    return fmt.Errorf(\"input %v does not match DoFn signature %v\", inType, expectedType)\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Match KV/single-value shapes between PCollections and DoFn signatures.","Read both types in the error message to see actual vs expected.","Add a graph-binding unit test for custom DoFns.","Reshape data (beam.KV / beam.ExtractKey) instead of loosening signatures."],"tags":["go","type-binding","dofn-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"}