{"record":{"id":"2588826666085814","repo":"apache/beam","slug":"cannot-provide-s-because-s-is-not-a-subclass-of-s-258882","errorCode":null,"errorMessage":"Cannot provide %s because %s is not a subclass of %s","messagePattern":"Cannot provide (.+?) because (.+?) is not a subclass of (.+?)","errorType":"exception","errorClass":"CannotProvideCoderException","httpStatus":null,"severity":"warning","filePath":"sdks/java/io/hbase/src/main/java/org/apache/beam/sdk/io/hbase/HBaseRowMutationsCoder.java","lineNumber":126,"sourceCode":"  /**\n   * Returns a {@link CoderProvider} which uses the {@link HBaseRowMutationsCoder} for {@link\n   * RowMutations}.\n   */\n  static CoderProvider getCoderProvider() {\n    return HBASE_ROW_MUTATIONS_CODER_PROVIDER;\n  }\n\n  private static final CoderProvider HBASE_ROW_MUTATIONS_CODER_PROVIDER =\n      new HBaseRowMutationsCoderProvider();\n\n  /** A {@link CoderProvider} for {@link Mutation mutations}. */\n  private static class HBaseRowMutationsCoderProvider extends CoderProvider {\n    @Override\n    public <T> Coder<T> coderFor(\n        TypeDescriptor<T> typeDescriptor, List<? extends Coder<?>> componentCoders)\n        throws CannotProvideCoderException {\n      if (!typeDescriptor.isSubtypeOf(HBASE_ROW_MUTATIONS_TYPE_DESCRIPTOR)) {\n        throw new CannotProvideCoderException(\n            String.format(\n                \"Cannot provide %s because %s is not a subclass of %s\",\n                HBaseRowMutationsCoder.class.getSimpleName(),\n                typeDescriptor,\n                Mutation.class.getName()));\n      }\n\n      try {\n        @SuppressWarnings(\"unchecked\")\n        Coder<T> coder = (Coder<T>) HBaseRowMutationsCoder.of();\n        return coder;\n      } catch (IllegalArgumentException e) {\n        throw new CannotProvideCoderException(e);\n      }\n    }\n  }\n\n  private static final TypeDescriptor<RowMutations> HBASE_ROW_MUTATIONS_TYPE_DESCRIPTOR =","sourceCodeStart":108,"sourceCodeEnd":144,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/io/hbase/src/main/java/org/apache/beam/sdk/io/hbase/HBaseRowMutationsCoder.java#L108-L144","documentation":"HBaseRowMutationsCoderProvider supplies HBaseRowMutationsCoder only for TypeDescriptors that are subtypes of RowMutations (descriptor check against HBASE_ROW_MUTATIONS_TYPE_DESCRIPTOR; the message text mentions Mutation). If the requested type isn't a match, it throws CannotProvideCoderException — expected behavior of the CoderProvider SPI.","triggerScenarios":"Beam coder registry asks this provider for a coder for type T; T is neither RowMutations nor a Mutation subtype, so the provider declines.","commonSituations":"Requesting default coders for POJOs or wrappers around RowMutations; confusion between Mutation-level coder and RowMutations coder; generic pipeline code losing concrete type info.","solutions":["Ensure the PCollection element type is exactly RowMutations when relying on this provider.","Use HBaseIO's expected types (Mutation for HBaseMutationCoder, RowMutations for this coder) or set the coder explicitly with setCoder().","Handle CannotProvideCoderException when querying coder registry programmatically and fall back to a registered coder.","Register your own Coder for custom wrapper types instead of relying on inference."],"exampleFix":"// before\nPCollection<MyWrapper> wrapped = ...; // no coder found\n// after\nPCollection<RowMutations> rms = wrapped.apply(MapElements.into(TypeDescriptor.of(RowMutations.class))...)\n    .setCoder(HBaseRowMutationsCoder.of());","handlingStrategy":"type-guard","validationCode":"TypeDescriptor<?> td = TypeDescriptor.of(pcoll.getCoder().getEncodedTypeDescriptor());\nif (!td.isSubtypeOf(TypeDescriptor.of(RowMutations.class))) {\n  pcoll.setCoder(HBaseRowMutationsCoder.of()); // only for RowMutations collections\n}","typeGuard":"static <T> boolean isRowMutationsType(TypeDescriptor<T> td) {\n  return td.isSubtypeOf(TypeDescriptor.of(RowMutations.class));\n}","tryCatchPattern":"try {\n  Coder<?> c = coderRegistry.getCoder(TypeDescriptor.of(MyWrapper.class));\n} catch (CannotProvideCoderException e) {\n  // unwrap to RowMutations or register an explicit coder\n  pcoll.setCoder(HBaseRowMutationsCoder.of());\n}","preventionTips":["Use RowMutations as the element type for multi-mutation-per-row writes.","Set HBaseRowMutationsCoder.of() explicitly instead of relying on inference.","Catch CannotProvideCoderException in coder-registry lookups and provide fallbacks.","Keep custom wrapper types registered with their own coders."],"tags":["hbase","coder","type-system","coder-provider"],"backgroundTag":"incompatible-source-type","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"}