{"record":{"id":"4016f96a48e38528","repo":"apache/beam","slug":"unexpected-inject-coder-v","errorCode":null,"errorMessage":"unexpected inject coder: %v","messagePattern":"unexpected inject coder: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/core/runtime/exec/translate.go","lineNumber":712,"sourceCode":"\t\t\t\tcase urnPerKeyCombineConvert:\n\t\t\t\t\tu = &ConvertToAccumulators{Combine: cn}\n\t\t\t\tdefault: // For unlifted combines\n\t\t\t\t\tu = cn\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tpanic(fmt.Sprintf(\"Opcode should be one of ParDo or Combine, but it is: %v\", op))\n\t\t\t}\n\n\t\tcase graphx.URNIterableSideInputKey:\n\t\t\tu = &FixedKey{UID: b.idgen.New(), Key: []byte(iterableSideInputKey), Out: out[0]}\n\n\t\tcase graphx.URNInject:\n\t\t\tc, _, err := b.makeCoderForPCollection(from)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err\n\t\t\t}\n\t\t\tif !coder.IsKV(c) {\n\t\t\t\treturn nil, errors.Errorf(\"unexpected inject coder: %v\", c)\n\t\t\t}\n\t\t\tvalCoder := c.Components[1]\n\t\t\t// JIRA BEAM-12438 - an extra LP coder can get added here, but isn't added\n\t\t\t// on decode. Strip them until we get a better fix.\n\t\t\tif valCoder.Kind == coder.LP {\n\t\t\t\t// strip unexpected length prefix coder.\n\t\t\t\tvalCoder = valCoder.Components[0]\n\t\t\t}\n\t\t\tu = &Inject{UID: b.idgen.New(), N: (int)(tp.GetInject().GetN()), ValueEncoder: MakeElementEncoder(valCoder), Out: out[0]}\n\n\t\tcase graphx.URNExpand:\n\t\t\tvar pid string\n\t\t\tfor _, id := range transform.GetOutputs() {\n\t\t\t\tpid = id\n\t\t\t}\n\t\t\tc, _, err := b.makeCoderForPCollection(pid)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, err","sourceCodeStart":694,"sourceCodeEnd":730,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/core/runtime/exec/translate.go#L694-L730","documentation":"The URNInject transform moves elements into a CoGBK-style output and requires the incoming PCollection's coder to be KV so the value coder can be separated for the Inject encoder. A non-KV coder here is an internal inconsistency in the translated coder graph and triggers this error.","triggerScenarios":"Coder for the 'from' PCollection of a Inject transform (used by beam.Flatten/CoGBK injection) decodes as non-KV — typically after coder payload corruption, custom coder fallback, or version-skewed coder inference between SDK and runner.","commonSituations":"Custom coders that change KV structure; pipelines crossing SDK version upgrades (BEAM-12438-adjacent LP coder handling); runners rewriting coder payloads.","solutions":["Keep SDK and runner on matching versions and resubmit the job","Inspect the coder payload for the injected PCollection to confirm it is KV; fix the custom coder's Encode/Decode or CreateCoder so structure is preserved","If an unexpected LP wrapper is involved, note it is stripped automatically — check whether a custom coder wraps values redundantly"],"exampleFix":"null","handlingStrategy":"validation","validationCode":"c, _, err := b.makeCoderForPCollection(from)\nif err != nil {\n\treturn err\n}\nif !coder.IsKV(c) {\n\treturn fmt.Errorf(\"inject input must be KV-coded, got %v\", c)\n}","typeGuard":"null","tryCatchPattern":"null","preventionTips":["Ensure custom coders preserve KV structure through encode/decode","Avoid wrapping values in redundant length-prefix coders","Pin SDK versions across builder, runner, and harness"],"tags":["go","apache-beam","coder","inject"],"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"}