{"record":{"id":"9b1d2b7b23d0d801","repo":"apache/beam","slug":"failure-to-register-coder","errorCode":null,"errorMessage":"Failure to register coder","messagePattern":"Failure to register coder","errorType":"exception","errorClass":"java.lang.RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/ParDoTranslation.java","lineNumber":723,"sourceCode":"      case SET_SPEC:\n        return StateSpecs.set(components.getCoder(stateSpec.getSetSpec().getElementCoderId()));\n\n      case ORDERED_LIST_SPEC:\n        return StateSpecs.orderedList(\n            components.getCoder(stateSpec.getOrderedListSpec().getElementCoderId()));\n\n      case SPEC_NOT_SET:\n      default:\n        throw new IllegalArgumentException(\n            String.format(\"Unknown %s: %s\", RunnerApi.StateSpec.class.getName(), stateSpec));\n    }\n  }\n\n  public static String registerCoderOrThrow(SdkComponents components, Coder coder) {\n    try {\n      return components.registerCoder(coder);\n    } catch (IOException exc) {\n      throw new RuntimeException(\"Failure to register coder\", exc);\n    }\n  }\n\n  public static RunnerApi.TimerFamilySpec translateTimerFamilySpec(\n      TimerSpec timer,\n      SdkComponents components,\n      Coder<?> keyCoder,\n      Coder<BoundedWindow> windowCoder) {\n    return RunnerApi.TimerFamilySpec.newBuilder()\n        .setTimeDomain(translateTimeDomain(timer.getTimeDomain()))\n        .setTimerFamilyCoderId(\n            registerCoderOrThrow(components, Timer.Coder.of(keyCoder, windowCoder)))\n        .build();\n  }\n\n  public static RunnerApi.TimeDomain.Enum translateTimeDomain(TimeDomain timeDomain) {\n    switch (timeDomain) {\n      case EVENT_TIME:","sourceCodeStart":705,"sourceCodeEnd":741,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/ParDoTranslation.java#L705-L741","documentation":"registerCoderOrThrow registers a Coder with the SdkComponents used to build the pipeline proto. Registration can throw IOException (coder cloud-encoding failures); since translation is not expected to fail on I/O, the checked exception is wrapped in a RuntimeException with this generic message, keeping the original as the cause.","triggerScenarios":"Calling ParDoTranslation.registerCoderOrThrow (directly or via ParDo translation) with a coder whose registerCoder call throws IOException — e.g. a custom Coder with a broken cloudObject encoding or a coder that fails verification during registration.","commonSituations":"Custom Coder implementations with faulty registerByteSizeObserver/getEncodedElementByteSize or cloud object serialization; classpath issues preventing reflective coder instantiation inside registration.","solutions":["Check the IOException cause in the stack trace to find which coder failed and why","Fix the custom Coder's serialization/verification methods so registration succeeds","Replace the problem coder with a standard Beam coder (e.g. AvroCoder, SerializableCoder)"],"exampleFix":"// before\nclass BrokenCoder<T> extends StructuredCoder<T> { /* getEncodedElementByteSize throws */ }\n// after\nclass FixedCoder<T> extends StructuredCoder<T> { @Override protected long getEncodedElementByteSize(T v) { return safeSize(v); } }","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { return ParDoTranslation.registerCoderOrThrow(components, coder); } catch (RuntimeException e) { throw new RuntimeException(\"Coder registration failed for \" + coder, e.getCause()); }","preventionTips":["Unit-test custom Coders' cloud object encoding and verification","Prefer standard Beam coders where possible","Keep coder dependencies on the runtime classpath"],"tags":["java","apache-beam","coder","runtime-exception"],"backgroundTag":"file-write-failed","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}