{"record":{"id":"e09fa1bea12098d3","repo":"apache/beam","slug":"unable-to-get-event-coder","errorCode":null,"errorMessage":"Unable to get event coder","messagePattern":"Unable to get event coder","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/ordered/src/main/java/org/apache/beam/sdk/extensions/ordered/OrderedEventProcessor.java","lineNumber":123,"sourceCode":"\n    final TupleTag<KV<EventKeyT, KV<Long, UnprocessedEvent<EventT>>>> unprocessedEventOutput =\n        new TupleTag<KV<EventKeyT, KV<Long, UnprocessedEvent<EventT>>>>(\"unprocessed-events\") {};\n\n    OrderedProcessingHandler<EventT, EventKeyT, StateT, ResultT> handler = getHandler();\n    Pipeline pipeline = input.getPipeline();\n\n    Coder<EventKeyT> keyCoder;\n    try {\n      keyCoder = handler.getKeyCoder(pipeline, input.getCoder());\n    } catch (CannotProvideCoderException e) {\n      throw new RuntimeException(\"Unable to get key coder\", e);\n    }\n\n    Coder<EventT> eventCoder;\n    try {\n      eventCoder = handler.getEventCoder(pipeline, input.getCoder());\n    } catch (CannotProvideCoderException e) {\n      throw new RuntimeException(\"Unable to get event coder\", e);\n    }\n\n    Coder<StateT> stateCoder;\n    try {\n      stateCoder = handler.getStateCoder(pipeline);\n    } catch (CannotProvideCoderException e) {\n      throw new RuntimeException(\"Unable to get state coder\", e);\n    }\n\n    Coder<ResultT> resultCoder;\n    try {\n      resultCoder = handler.getResultCoder(pipeline);\n    } catch (CannotProvideCoderException e) {\n      throw new RuntimeException(\"Unable to get result coder\", e);\n    }\n\n    KvCoder<EventKeyT, ResultT> mainOutputCoder = KvCoder.of(keyCoder, resultCoder);\n    KvCoder<EventKeyT, OrderedProcessingStatus> processingStatusCoder =","sourceCodeStart":105,"sourceCodeEnd":141,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/ordered/src/main/java/org/apache/beam/sdk/extensions/ordered/OrderedEventProcessor.java#L105-L141","documentation":"OrderedEventProcessor.expand() obtains a Coder for the event value type EventT via handler.getEventCoder(pipeline, input.getCoder()). When the coder cannot be inferred from the input's KvCoder, it wraps CannotProvideCoderException in this RuntimeException. Beam needs the event coder to serialize events (including unprocessed-event buffering) across stages.","triggerScenarios":"expand() applied to a PCollection<KV<EventKeyT, EventT>> whose value coder is unresolvable: value type is a custom class with no CoderProvider, input built via Create.of with erased generics, or coder inference throws CannotProvideCoderException in getEventCoder.","commonSituations":"Custom event POJOs lacking @DefaultCoder or a registered CoderProvider; using types like Object or raw generics; beam coder inference failing after a refactor changed the value type.","solutions":["Set an explicit KvCoder on the input PCollection with setCoder(KvCoder.of(keyCoder, eventCoder)) before expand().","Annotate the event class with @DefaultCoder(AvroCoder.class) or register a CoderProvider in CoderRegistry.","Override getEventCoder in your handler to return an explicit coder.","Verify the generic type parameters of the PCollection are concrete, not type-erased."],"exampleFix":"// before\nPCollection<KV<String, MyEvent>> in = ...;\n// after\nPCollection<KV<String, MyEvent>> in = in.setCoder(KvCoder.of(StringUtf8Coder.of(), AvroCoder.of(MyEvent.class)));","handlingStrategy":"validation","validationCode":"if (!(input.getCoder() instanceof KvCoder)) {\n  throw new IllegalArgumentException(\"set KvCoder.of(keyCoder, eventCoder) on the input before expand()\");\n}","typeGuard":"static boolean hasValueCoder(PCollection<?> pc) {\n  return pc.getCoder() instanceof KvCoder && ((KvCoder<?, ?>) pc.getCoder()).getValueCoder() != null;\n}","tryCatchPattern":"try {\n  processor.expand(input);\n} catch (RuntimeException e) {\n  if (e.getCause() instanceof CannotProvideCoderException) {\n    input.setCoder(KvCoder.of(keyCoder, AvroCoder.of(EventT.class)));\n    processor.expand(input);\n  } else { throw e; }\n}","preventionTips":["Annotate event POJOs with @DefaultCoder","Set explicit coders on every PCollection feeding the processor","Keep generic type parameters concrete (avoid raw types)"],"tags":["apache-beam","coder","serialization","pipeline-construction"],"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"}