{"record":{"id":"0e4c2bee2c079b8d","repo":"apache/beam","slug":"solaceio-read-cannot-infer-a-coder-for-the-typedescriptor","errorCode":null,"errorMessage":"SolaceIO.Read: Cannot infer a coder for the TypeDescriptor. Annotate your output class with @DefaultSchema annotation or create a coder manually and register it in the CoderRegistry.","messagePattern":"SolaceIO\\.Read: Cannot infer a coder for the TypeDescriptor\\. Annotate your output class with @DefaultSchema annotation or create a coder manually and register it in the CoderRegistry\\.","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/SolaceIO.java","lineNumber":824,"sourceCode":"                  configuration.getWatermarkIdleDurationThreshold(),\n                  configuration.getParseFn(),\n                  configuration.getAckDeadline(),\n                  configuration.getNackOnTimeout())));\n    }\n\n    @VisibleForTesting\n    Coder<T> inferCoder(Pipeline pipeline, TypeDescriptor<T> typeDescriptor) {\n      Coder<T> coderFromCoderRegistry = getFromCoderRegistry(pipeline, typeDescriptor);\n      if (coderFromCoderRegistry != null) {\n        return coderFromCoderRegistry;\n      }\n\n      Coder<T> coderFromSchemaRegistry = getFromSchemaRegistry(pipeline, typeDescriptor);\n      if (coderFromSchemaRegistry != null) {\n        return coderFromSchemaRegistry;\n      }\n\n      throw new RuntimeException(\n          \"SolaceIO.Read: Cannot infer a coder for the TypeDescriptor. Annotate your\"\n              + \" output class with @DefaultSchema annotation or create a coder manually\"\n              + \" and register it in the CoderRegistry.\");\n    }\n\n    private @Nullable Coder<T> getFromSchemaRegistry(\n        Pipeline pipeline, TypeDescriptor<T> typeDescriptor) {\n      try {\n        return pipeline.getSchemaRegistry().getSchemaCoder(typeDescriptor);\n      } catch (NoSuchSchemaException e) {\n        return null;\n      }\n    }\n\n    private @Nullable Coder<T> getFromCoderRegistry(\n        Pipeline pipeline, TypeDescriptor<T> typeDescriptor) {\n      try {\n        return pipeline.getCoderRegistry().getCoder(typeDescriptor);","sourceCodeStart":806,"sourceCodeEnd":842,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/solace/src/main/java/org/apache/beam/sdk/io/solace/SolaceIO.java#L806-L842","documentation":"SolaceIO.Read must produce a Coder for the user's output type. It first checks the CoderRegistry, then tries to infer a coder from a registered schema (@DefaultSchema); if both fail it throws this RuntimeException. Beam cannot serialize pipeline elements without a coder.","triggerScenarios":"Calling SolaceIO.read() with .withTypeDescriptor(TypeDescriptor.of(SomeClass)) (or a custom mapper returning SomeClass) where SomeClass has no registered coder and is not annotated with @DefaultSchema / has no schema provider in the registry.","commonSituations":"Using a plain POJO without @DefaultSchema; forgetting to call pipeline.getCoderRegistry().registerCoderForClass or register the Schema; custom mapper output type not matching the annotated type.","solutions":["Annotate the output class with @DefaultSchema(JavaBeanSchema.class) (or AutoValue/POJO schema).","Register a coder explicitly: pipeline.getCoderRegistry().registerCoderForClass(MyClass.class, new MyClassCoder()).","Ensure the TypeDescriptor passed to withTypeDescriptor matches the class actually output by your mapper.","As a workaround, map to a primitive/serializable type (e.g. String) that has a built-in coder."],"exampleFix":"// before\npublic class Order { private String id; /* getters/setters */ }\n// after\n@DefaultSchema(JavaBeanSchema.class)\npublic class Order { private String id; /* getters/setters */ }","handlingStrategy":"validation","validationCode":"// Ensure a coder/schema exists before building the read\n// boolean hasSchema = Order.class.isAnnotationPresent(DefaultSchema.class);\n// boolean hasCoder = pipeline.getCoderRegistry().getCoder(TypeDescriptor.of(Order.class)) != null;","typeGuard":"<T> boolean codable(Pipeline p, TypeDescriptor<T> td) {\n  try { p.getCoderRegistry().getCoder(td); return true; } catch (CannotProvideCoderException e) { return false; }\n}","tryCatchPattern":"try { SolaceIO.read()...apply(); }\ncatch (RuntimeException e) {\n  if (e.getMessage().contains(\"Cannot infer a coder\")) registerSchemaOrCoder();\n  else throw e;\n}","preventionTips":["Always annotate output POJOs with @DefaultSchema(JavaBeanSchema.class) when using SolaceIO.Read.","Or register an explicit coder in the CoderRegistry for custom classes.","Keep the TypeDescriptor, mapper output type, and annotated class consistent."],"tags":["solace","beam","coder","schema"],"backgroundTag":"schema-validation-failed","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"}