{"record":{"id":"9f1e0171997d11c6","repo":"apache/beam","slug":"todo-add-support-for-reading-the-timestamp-from-the-encoded","errorCode":null,"errorMessage":"TODO: Add support for reading the timestamp from the encoded window.","messagePattern":"TODO: Add support for reading the timestamp from the encoded window\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/fn/windowing/EncodedBoundedWindow.java","lineNumber":48,"sourceCode":"import org.joda.time.Instant;\n\n/**\n * An encoded {@link BoundedWindow} used within Runners to track window information without needing\n * to decode the window.\n *\n * <p>This allows for Runners to not need to know window format during execution.\n */\n@AutoValue\npublic abstract class EncodedBoundedWindow extends BoundedWindow {\n  public static EncodedBoundedWindow forEncoding(ByteString encodedWindow) {\n    return new AutoValue_EncodedBoundedWindow(encodedWindow);\n  }\n\n  public abstract ByteString getEncodedWindow();\n\n  @Override\n  public Instant maxTimestamp() {\n    throw new UnsupportedOperationException(\n        \"TODO: Add support for reading the timestamp from \" + \"the encoded window.\");\n  }\n\n  /**\n   * An {@link Coder} for {@link EncodedBoundedWindow}s.\n   *\n   * <p>This is a copy of {@code ByteStringCoder} to prevent a dependency on {@code\n   * beam-java-sdk-extensions-protobuf}.\n   */\n  public static class Coder extends AtomicCoder<EncodedBoundedWindow> {\n    public static final Coder INSTANCE = new Coder();\n\n    // prevent instantiation\n    private Coder() {}\n\n    @Override\n    public void encode(EncodedBoundedWindow value, OutputStream outStream)\n        throws CoderException, IOException {","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/fn/windowing/EncodedBoundedWindow.java#L30-L66","documentation":"EncodedBoundedWindow represents a window only by its encoded bytes; the Fn API windowing protocol does not carry the window's end timestamp, so maxTimestamp() cannot be computed. It therefore throws UnsupportedOperationException signaling that reading a timestamp from the encoded window is not implemented.","triggerScenarios":"Calling maxTimestamp() on any EncodedBoundedWindow instance, e.g. applying window.maxTimestamp() to windows received over the Fn API.","commonSituations":"User code or transforms assuming concrete BoundedWindow semantics applied to Fn harness windows; tests exercising watermark holds with encoded windows.","solutions":["Do not call maxTimestamp() on EncodedBoundedWindow; restructure to use window boundary info available elsewhere","Decode the encoded window into a real BoundedWindow (e.g. IntervalWindow) using the appropriate Coder before querying timestamps","Use known window semantics (e.g. GlobalWindow.INSTANCE.maxTimestamp()) when the window type is statically known","Implement support in a custom window subclass if timestamp extraction is required"],"exampleFix":"// before\nInstant ts = encodedWindow.maxTimestamp(); // throws\n// after\nBoundedWindow w = windowCoder.decode(encodedWindow.getEncodedWindow().newInput());\nInstant ts = w.maxTimestamp();","handlingStrategy":"type-guard","validationCode":"if (window instanceof EncodedBoundedWindow) {\n  throw new IllegalStateException(\"maxTimestamp unsupported for encoded windows\");\n}","typeGuard":"static boolean hasTimestamp(BoundedWindow w) {\n  return !(w instanceof EncodedBoundedWindow);\n}","tryCatchPattern":"try {\n  return window.maxTimestamp();\n} catch (UnsupportedOperationException e) {\n  return GlobalWindow.INSTANCE.maxTimestamp();\n}","preventionTips":["Do not rely on maxTimestamp() when consuming Fn-harness windows","Decode encoded windows with the proper window Coder first","Restrict window-timestamp logic to concrete window types (IntervalWindow, GlobalWindow)"],"tags":["java","beam","windows","unsupported"],"backgroundTag":"method-not-implemented","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"}