{"record":{"id":"81b06307bdc35016","repo":"apache/beam","slug":"unable-to-rewrite-coder-v-for-state-v-for-transform-v-in","errorCode":null,"errorMessage":"unable to rewrite coder %v for state %v for transform %v in stage %v:%w","messagePattern":"unable to rewrite coder (.+?) for state (.+?) for transform (.+?) in stage (.+?):%w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"sdks/go/pkg/beam/runners/prism/internal/stage.go","lineNumber":459,"sourceCode":"\t\tif t.GetSpec().GetUrn() != urns.TransformParDo {\n\t\t\tcontinue\n\t\t}\n\n\t\tpardo := &pipepb.ParDoPayload{}\n\t\tif err := (proto.UnmarshalOptions{}).Unmarshal(t.GetSpec().GetPayload(), pardo); err != nil {\n\t\t\treturn fmt.Errorf(\"unable to decode ParDoPayload for %v in stage %v\", tid, stg.ID)\n\t\t}\n\n\t\t// We need to ensure the coders can be handled by prism, and are available in the bundle descriptor.\n\t\t// So we rewrite the transform's Payload with updated coder ids here.\n\t\tvar rewrite bool\n\t\tvar rewriteErr error\n\t\tfor stateID, s := range pardo.GetStateSpecs() {\n\t\t\trewrite = true\n\t\t\trewriteCoder := func(cid *string) {\n\t\t\t\tnewCid, err := lpUnknownCoders(*cid, coders, comps.GetCoders())\n\t\t\t\tif err != nil {\n\t\t\t\t\trewriteErr = fmt.Errorf(\"unable to rewrite coder %v for state %v for transform %v in stage %v:%w\", *cid, stateID, tid, stg.ID, err)\n\t\t\t\t\treturn\n\t\t\t\t}\n\t\t\t\t*cid = newCid\n\t\t\t}\n\t\t\tswitch s := s.GetSpec().(type) {\n\t\t\tcase *pipepb.StateSpec_BagSpec:\n\t\t\t\trewriteCoder(&s.BagSpec.ElementCoderId)\n\t\t\tcase *pipepb.StateSpec_SetSpec:\n\t\t\t\trewriteCoder(&s.SetSpec.ElementCoderId)\n\t\t\tcase *pipepb.StateSpec_OrderedListSpec:\n\t\t\t\trewriteCoder(&s.OrderedListSpec.ElementCoderId)\n\t\t\t\t// Add the length determination helper for OrderedList state values.\n\t\t\t\tif stg.stateTypeLen == nil {\n\t\t\t\t\tstg.stateTypeLen = map[engine.LinkID]func([]byte) int{}\n\t\t\t\t}\n\t\t\t\tlinkID := engine.LinkID{\n\t\t\t\t\tTransform: tid,\n\t\t\t\t\tLocal:     stateID,","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/go/pkg/beam/runners/prism/internal/stage.go#L441-L477","documentation":"When prism rewrites state coder IDs in a ParDoPayload so coders exist in the bundle descriptor, lpUnknownCoders may fail; this error wraps that failure with the coder ID, state ID, transform, and stage. The original cause is preserved via %w.","triggerScenarios":"A state spec (bag, map, set, etc.) references a coder ID that lpUnknownCoders cannot find or rewrite in comps.GetCoders() — typically a dangling or unsupported coder reference in the pipeline components.","commonSituations":"Stateful DoFns from SDKs whose generated coders prism can't handle; cross-language stateful transforms with unknown coders; version skew altering coder IDs.","solutions":["Read the wrapped cause (%w) for why the coder rewrite failed","Ensure all state coders are standard supported coders (bytes, varint, length-prefix)","Check the pipeline components section includes the referenced coder definitions","Avoid custom coders for state in pipelines targeting prism, or upgrade Beam"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"for cid := range pardo.GetStateSpecs() {\n    if comps.GetCoders()[cid] == nil {\n        return fmt.Errorf(\"state coder %v missing from components\", cid)\n    }\n}","typeGuard":null,"tryCatchPattern":"if err := buildDescriptor(...); err != nil {\n    var wrappedErr error\n    if errors.As(err, &wrappedErr) && strings.Contains(err.Error(), \"unable to rewrite coder\") {\n        // inspect wrapped cause via errors.Unwrap\n    }\n    return err\n}","preventionTips":["Use standard coders for DoFn state","Ensure all referenced coders exist in pipeline components","Test stateful pipelines against prism before production"],"tags":["go","beam","state","coder"],"backgroundTag":"coder-rewrite-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-15T13:17:12.816Z"}