{"record":{"id":"e23fad5d521889d1","repo":"apache/beam","slug":"cannot-provide-s-given-type-descriptor-s-s-raw-type-is-not","errorCode":null,"errorMessage":"Cannot provide [%s], given type descriptor's [%s] raw type is not registered in Kryo.","messagePattern":"Cannot provide \\[(.+?)\\], given type descriptor's \\[(.+?)\\] raw type is not registered in Kryo\\.","errorType":"exception","errorClass":"CannotProvideCoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/extensions/kryo/src/main/java/org/apache/beam/sdk/extensions/kryo/KryoCoderProvider.java","lineNumber":128,"sourceCode":"  /** {@link KryoRegistrar}s associated with this provider instance. */\n  private final KryoCoder<?> coder;\n\n  private KryoCoderProvider(KryoCoder<?> coder) {\n    this.coder = coder;\n  }\n\n  @Override\n  @SuppressWarnings(\"unchecked\")\n  public <T> Coder<T> coderFor(\n      TypeDescriptor<T> typeDescriptor, List<? extends Coder<?>> componentCoders)\n      throws CannotProvideCoderException {\n    if (hasUserProvidedRegistration(typeDescriptor)) {\n      return (Coder) coder;\n    }\n    if (OBJECT_TYPE.equals(typeDescriptor)) {\n      return (Coder) coder;\n    }\n    throw new CannotProvideCoderException(\n        String.format(\n            \"Cannot provide [%s], given type descriptor's [%s] raw type is not registered in Kryo.\",\n            KryoCoder.class.getSimpleName(), typeDescriptor));\n  }\n\n  private <T> boolean hasUserProvidedRegistration(TypeDescriptor<T> typeDescriptor) {\n    final KryoState kryoState = KryoState.get(coder);\n    final Class<? super T> rawType = typeDescriptor.getRawType();\n    final Kryo kryo = kryoState.getKryo();\n    final ClassResolver classResolver = kryo.getClassResolver();\n    final Registration registration = classResolver.getRegistration(rawType);\n    return registration != null && registration.getId() >= kryoState.getFirstRegistrationId();\n  }\n\n  /**\n   * Create a new {@link KryoCoderProvider} with the provided registrar.\n   *\n   * @param registrar registrar to append to the list of already registered registrars.","sourceCodeStart":110,"sourceCodeEnd":146,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/extensions/kryo/src/main/java/org/apache/beam/sdk/extensions/kryo/KryoCoderProvider.java#L110-L146","documentation":"KryoCoderProvider.coderFor is asked to supply a Coder for a type. If the type is not explicitly registered with Kryo (no user-provided registration) and is not plain java.lang.Object, the provider cannot safely hand out a KryoCoder and throws CannotProvideCoderException. This prevents silently serializing unregistered classes when registration is expected.","triggerScenarios":"Calling CoderRegistry.getCoder(TypeDescriptor) (or using a pipeline where coder inference runs) for a class that has no Kryo registration and no user-provided coder, when the Kryo configuration requires explicit registration.","commonSituations":"Passing a custom POJO through a Beam pipeline without registering it via KryoOptions/registration or @DefaultCoder; refactoring a type so coder inference no longer finds a registered Kryo mapping.","solutions":["Register the class with Kryo (e.g. via KryoOptions registrations or a KryoRegistrar) so hasUserProvidedRegistration succeeds.","Annotate the type with @DefaultCoder or supply an explicit Coder via setCoder.","If truly dynamic/untyped use is intended, pass a TypeDescriptor for java.lang.Object, which the provider short-circuits.","Switch the class to a registered serializable type or a Beam-native coder (SerializableCoder/AvroCoder)."],"exampleFix":"// before\nPCollection<MyPojo> out = pipeline.apply(...); // MyPojo unregistered -> CannotProvideCoderException\n// after\nKryoOptions options = KryoOptions.widenBytesAndStrings(false).withRegistrations(ImmutableList.of(new Registration(MyPojo.class, 1000)));\nPCollection<MyPojo> out = pipeline.apply(...).setCoder(KryoCoder.of(options));","handlingStrategy":"validation","validationCode":"KryoOptions options = ...; if (!options.isRegistered(MyPojo.class)) registerOrProvideCoder(MyPojo.class);","typeGuard":null,"tryCatchPattern":"try { Coder<T> c = registry.getCoder(TypeDescriptor.of(MyPojo.class)); } catch (CannotProvideCoderException e) { /* register type and retry */ }","preventionTips":["Register every custom type passed through Beam PCollections","Use @DefaultCoder for types with a fixed coder","Run coder inference in unit tests before launching jobs","Prefer Beam-native coders for simple POJOs"],"tags":["java","kryo","coder","apache-beam"],"backgroundTag":"missing-required-config","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"}