{"record":{"id":"05d12bfc8c4fdbb2","repo":"apache/beam","slug":"unable-to-infer-a-coder-and-no-coder-was-specified-please-05d12b","errorCode":null,"errorMessage":"Unable to infer a coder and no Coder was specified. Please set a coder by invoking CreateTimestamped.withCoder() explicitly.","messagePattern":"Unable to infer a coder and no Coder was specified\\. Please set a coder by invoking CreateTimestamped\\.withCoder\\(\\) explicitly\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java","lineNumber":730,"sourceCode":"          }\n          if (coder == null) {\n            coder = coderRegistry.getCoder(typeDescriptor.get());\n          }\n        } else {\n          Iterable<T> rawElements =\n              Iterables.transform(timestampedElements, TimestampedValue::getValue);\n          coder = getDefaultCreateCoder(coderRegistry, schemaRegistry, rawElements);\n        }\n\n        PCollection<TimestampedValue<T>> intermediate =\n            Pipeline.applyTransform(\n                input, Create.of(timestampedElements).withCoder(TimestampedValueCoder.of(coder)));\n\n        PCollection<T> output = intermediate.apply(ParDo.of(new ConvertTimestamps<>()));\n        output.setCoder(coder);\n        return output;\n      } catch (CannotProvideCoderException e) {\n        throw new IllegalArgumentException(\n            \"Unable to infer a coder and no Coder was specified. \"\n                + \"Please set a coder by invoking CreateTimestamped.withCoder() explicitly.\",\n            e);\n      }\n    }\n\n    /////////////////////////////////////////////////////////////////////////////\n\n    /** The timestamped elements of the resulting PCollection. */\n    private final transient Iterable<TimestampedValue<T>> timestampedElements;\n\n    /** The coder used to encode the values to and from a binary representation. */\n    private final transient Optional<Coder<T>> elementCoder;\n\n    /** The value type. */\n    private final transient Optional<TypeDescriptor<T>> typeDescriptor;\n\n    private TimestampedValues(","sourceCodeStart":712,"sourceCodeEnd":748,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/Create.java#L712-L748","documentation":"CreateTimestamped<T> must code both the TimestampedValue elements and the output PCollection; when no coder is given via withCoder() and inference from T fails (CannotProvideCoderException), expand() throws this IllegalArgumentException. The message specifically directs users to CreateTimestamped.withCoder().","triggerScenarios":"Calling Create.timestamped(...) (or CreateTimestamped.of) with elements whose type has no default coder (POJO, interface, Object) and not chaining .withCoder(...).","commonSituations":"Creating timestamped test data with custom types; generics/type-erased collections passed to Create.timestamped; forgetting that TimestampedValueCoder still needs an inner coder for T.","solutions":["Add .withCoder(MyCoder.of()) (or TimestampedValueCoder.of(inner)) to the CreateTimestamped transform.","Register a default coder for T in the pipeline's CoderRegistry.","For POJOs, use .withSchema(...) or annotate the class so schema inference can supply a coder.","Extract elements into an explicitly-typed variable to help coder inference before building the transform."],"exampleFix":"// before\np.apply(Create.timestamped(TimestampedValue.of(myObj, Instant.now()))); // inference fails\n// after\np.apply(Create.timestamped(TimestampedValue.of(myObj, Instant.now()))\n    .withCoder(SerializableCoder.of(MyObj.class)));","handlingStrategy":"validation","validationCode":"try { p.getCoderRegistry().getCoder(TypeDescriptor.of(MyType.class)); } catch (CannotProvideCoderException e) { /* chain .withCoder */ }","typeGuard":null,"tryCatchPattern":"try { p.apply(Create.timestamped(vals)); } catch (IllegalArgumentException e) { if (e.getMessage().contains(\"CreateTimestamped.withCoder\")) { p.apply(Create.timestamped(vals).withCoder(myCoder)); } else throw e; }","preventionTips":["Always supply .withCoder for CreateTimestamped with custom types","Register default coders for domain types in CoderRegistry","Use concrete (non-generic) element types at call sites"],"tags":["java","apache-beam","create","timestamps","coder-inference"],"backgroundTag":"missing-required-argument","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"}