{"record":{"id":"63169eabc392b191","repo":"apache/beam","slug":"multimap-side-inputs-needs-kv-coder-got-v","errorCode":null,"errorMessage":"multimap side inputs needs KV coder, got %v","messagePattern":"multimap side inputs needs KV coder, got (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/prism/internal/stage.go","lineNumber":734,"sourceCode":"\t\t\tif b.IterableSideInputData == nil {\n\t\t\t\tb.IterableSideInputData = map[worker.SideInputKey]map[typex.Window][][]byte{}\n\t\t\t}\n\t\t\tb.IterableSideInputData[worker.SideInputKey{\n\t\t\t\tTransformID: link.Transform,\n\t\t\t\tLocal:       link.Local,\n\t\t\t}] = data\n\t\t}, nil\n\n\tcase urns.SideInputMultiMap:\n\t\tslog.Debug(\"urnSideInputMultiMap\",\n\t\t\tslog.String(\"sourceTransform\", t.GetUniqueName()),\n\t\t\tslog.String(\"local\", link.Local),\n\t\t\tslog.String(\"global\", link.Global))\n\t\tcol := pcols[link.Global]\n\n\t\tkvc := comps.GetCoders()[col.GetCoderId()]\n\t\tif kvc.GetSpec().GetUrn() != urns.CoderKV {\n\t\t\treturn nil, fmt.Errorf(\"multimap side inputs needs KV coder, got %v\", kvc.GetSpec().GetUrn())\n\t\t}\n\n\t\tkd := collectionPullDecoder(kvc.GetComponentCoderIds()[0], coders, comps)\n\t\tvd := collectionPullDecoder(kvc.GetComponentCoderIds()[1], coders, comps)\n\n\t\t// The returned coders are unused here, but they add the side input coders\n\t\t// to the stage components for use SDK side.\n\t\tgetWindowValueCoders(comps, col, coders)\n\t\treturn func(b *worker.B, watermark mtime.Time) {\n\t\t\t// May be of zero length, but that's OK. Side inputs can be empty.\n\t\t\tdata := em.GetSideData(b.PBDID, link.Transform, link.Local, watermark)\n\t\t\tif b.MultiMapSideInputData == nil {\n\t\t\t\tb.MultiMapSideInputData = map[worker.SideInputKey]map[typex.Window]map[string][][]byte{}\n\t\t\t}\n\n\t\t\twindowed := map[typex.Window]map[string][][]byte{}\n\t\t\tfor win, ds := range data {\n\t\t\t\tif len(ds) == 0 {","sourceCodeStart":716,"sourceCodeEnd":752,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/stage.go#L716-L752","documentation":"Multimap side inputs require the input PCollection to be a KV pair so keys can be mapped to lists of values. If the coder's URN is not beam:coder:kv, handleSideInput rejects the access pattern with this error, naming the actual URN found.","triggerScenarios":"A pipeline uses a multimap side input access pattern while the side input PCollection's coder is not a KV coder (e.g. a plain element coder, or an iterable/window coder instead of KV).","commonSituations":"Using beam.AsMap or multimap views over non-K<->V collections; forgetting beam.KV for side input elements; SDK constructs emitting windowed values instead of KV.","solutions":["Ensure the side input PCollection is a KV collection (beam.KV) before using a multimap view","Use beam.AsMap (single-map) instead of multimap view if elements are not KV","Check that upstream ParDo outputs KV-coded PCollections","Inspect the reported URN in the message to confirm the coder type mismatch"],"exampleFix":"// before\nsi := beam.SideInput(pcoll) // pcoll is of type T, not KV\n// after\nkvPcol := beam.ParDo(p, func(t T) (K, V) {...}, input)\nsi := beam.SideInput(kvPcol) // KV coder required for multimap","handlingStrategy":"type-guard","validationCode":"// Before using a multimap side input, assert KV typing\ncoderURN := coderURNOf(sideInputPcol)\nif coderURN != \"beam:coder:kv:v1\" {\n    return fmt.Errorf(\"multimap side input requires KV, got %s\", coderURN)\n}","typeGuard":"func isKVCoder(c *pipepb.Coder) bool {\n    return c.GetSpec().GetUrn() == \"beam:coder:kv:v1\"\n}","tryCatchPattern":null,"preventionTips":["Always build side inputs from KV-typed PCollections for multimap views","Use beam.Kv explicitly when in doubt","Prefer AsMap for non-KV collections"],"tags":["beam","prism","side-input","kv"],"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"}