{"record":{"id":"f95aa231094a3f4b","repo":"apache/beam","slug":"s-is-not-one-of-the-common-types","errorCode":null,"errorMessage":"%s is not one of the common types.","messagePattern":"(.+?) is not one of the common types\\.","errorType":"exception","errorClass":"CannotProvideCoderException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java","lineNumber":159,"sourceCode":"      builder.put(\n          ValueKind.class, CoderProviders.fromStaticMethods(ValueKind.class, ValueKindCoder.class));\n      builder.put(Void.class, CoderProviders.fromStaticMethods(Void.class, VoidCoder.class));\n      builder.put(\n          byte[].class, CoderProviders.fromStaticMethods(byte[].class, ByteArrayCoder.class));\n      builder.put(\n          IntervalWindow.class,\n          CoderProviders.forCoder(\n              TypeDescriptor.of(IntervalWindow.class), IntervalWindow.getCoder()));\n      commonTypesToCoderProviders = builder.build();\n    }\n\n    @Override\n    public <T> Coder<T> coderFor(\n        TypeDescriptor<T> typeDescriptor, List<? extends Coder<?>> componentCoders)\n        throws CannotProvideCoderException {\n      CoderProvider factory = commonTypesToCoderProviders.get(typeDescriptor.getRawType());\n      if (factory == null) {\n        throw new CannotProvideCoderException(\n            String.format(\"%s is not one of the common types.\", typeDescriptor));\n      }\n      return factory.coderFor(typeDescriptor, componentCoders);\n    }\n  }\n\n  static {\n    // Register the standard coders first so they are chosen over ServiceLoader ones\n    List<CoderProvider> codersToRegister = new ArrayList<>();\n    codersToRegister.add(new CommonTypes());\n\n    // Enumerate all the CoderRegistrars in a deterministic order, adding all coders to register\n    Set<CoderProviderRegistrar> registrars = Sets.newTreeSet(ObjectsClassComparator.INSTANCE);\n    registrars.addAll(\n        Lists.newArrayList(\n            ServiceLoader.load(CoderProviderRegistrar.class, ReflectHelpers.findClassLoader())));\n\n    // DefaultCoder should have the highest precedence and SerializableCoder the lowest","sourceCodeStart":141,"sourceCodeEnd":177,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/coders/CoderRegistry.java#L141-L177","documentation":"The CoderRegistry's built-in common-types coder provider only resolves coders for a fixed set of well-known Java types (e.g. String, Integer, Long, byte[], KVs). If coderFor is called with a TypeDescriptor whose raw type is not in that map, it throws CannotProvideCoderException stating the type is not one of the common types.","triggerScenarios":"Calling CoderRegistry.getCoder / getDefaultOutputCoder for a custom class that relies on the registry's default common-type resolution rather than having a registered coder or @DefaultCoder annotation.","commonSituations":"Custom POJO / AutoValue element types in a DoFn output without a registered coder; upgrading Beam where the inferred type changed; forgetting registerCoderForClass for user types before applying transforms.","solutions":["Register a coder for the custom type: registry.registerCoderForClass(MyType.class, MyTypeCoder.class)","Annotate the class with @DefaultCoder(MyTypeCoder.class)","Provide the coder explicitly at the transform (e.g. apply(...).setCoder(...)) or via getCoder overrides","If the type genuinely is a common type, check the TypeDescriptor's raw type — generics erasure may have resolved it to an unexpected raw type"],"exampleFix":"// before\nPCollection<MyType> out = rows.apply(ParDo.of(fn)); // CannotProvideCoderException\n// after\np.getCoderRegistry().registerCoderForClass(MyType.class, new MyTypeCoder());\nPCollection<MyType> out = rows.apply(ParDo.of(fn));","handlingStrategy":"fallback","validationCode":"CoderRegistry registry = p.getCoderRegistry();\nif (registry.getCoder(MyType.class) == null) { registry.registerCoderForClass(MyType.class, new MyTypeCoder()); }","typeGuard":"boolean hasDefaultCoder = java.util.Arrays.stream(CommonTypes.values()).anyMatch(t -> t.cls.equals(typeDescriptor.getRawType()));","tryCatchPattern":"try {\n  coder = registry.getCoder(MyType.class);\n} catch (CannotProvideCoderException e) {\n  coder = new MyTypeCoder(); // explicit fallback\n}","preventionTips":["Always register coders for custom element types at pipeline construction","Use @DefaultCoder on POJOs and AutoValue classes","Pass explicit TypeDescriptor to transforms so inference resolves to a registered type"],"tags":["java","apache-beam","coders","type-resolution"],"backgroundTag":"resource-not-found","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}