{"record":{"id":"b277688c52c79e1e","repo":"apache/beam","slug":"attempted-to-get-side-input-window-for-globalwindow-from-non-b27768","errorCode":null,"errorMessage":"Attempted to get side input window for GlobalWindow from non-global WindowFn","messagePattern":"Attempted to get side input window for GlobalWindow from non-global WindowFn","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/SlidingWindows.java","lineNumber":129,"sourceCode":"    for (long start = lastStart;\n        start > timestamp.minus(size).getMillis();\n        start -= period.getMillis()) {\n      windows.add(new IntervalWindow(new Instant(start), size));\n    }\n    return windows;\n  }\n\n  /**\n   * Return a {@link WindowMappingFn} that returns the earliest window that contains the end of the\n   * main-input window.\n   */\n  @Override\n  public WindowMappingFn<IntervalWindow> getDefaultWindowMappingFn() {\n    return new WindowMappingFn<IntervalWindow>() {\n      @Override\n      public IntervalWindow getSideInputWindow(BoundedWindow mainWindow) {\n        if (mainWindow instanceof GlobalWindow) {\n          throw new IllegalArgumentException(\n              \"Attempted to get side input window for GlobalWindow from non-global WindowFn\");\n        }\n        long lastStart = lastStartFor(mainWindow.maxTimestamp().minus(size));\n        return new IntervalWindow(new Instant(lastStart + period.getMillis()), size);\n      }\n    };\n  }\n\n  @Override\n  public boolean isCompatible(WindowFn<?, ?> other) {\n    return equals(other);\n  }\n\n  @Override\n  public boolean assignsToOneWindow() {\n    return !this.period.isShorterThan(this.size);\n  }\n","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/windowing/SlidingWindows.java#L111-L147","documentation":"Like PartitioningWindowFn, SlidingWindows' default side-input mapping cannot map GlobalWindow (which has no timestamp) onto a sliding IntervalWindow, so getSideInputWindow throws IllegalArgumentException when handed a GlobalWindow. The mapping is only defined for time-windowed main inputs.","triggerScenarios":"Requesting a side input whose PCollection uses SlidingWindows while the main element is in the GlobalWindow — i.e. getSideInputWindow(GlobalWindow.INSTANCE) on the SlidingWindows mapping fn.","commonSituations":"Unwindowed/bounded main PCollection reading a sliding-window side input; combining a batch (global window) source with a streaming sliding-window view in the same DoFn.","solutions":["Window the main input with SlidingWindows (or a compatible time windowfn) before sideInput","Re-window the side input to GlobalWindows if a global view is intended","Use FixedWindows on the side input with a WindowMappingFn you control","Align both PCollections with the same Window.into() call"],"exampleFix":"// before\nPCollectionView<X> v = slidingPco.apply(View.asMap());\nboundedPco.apply(ParDo.of(new DoFn<T,U>(){ @ProcessElement void p(ProcessContext c){ c.sideInput(v);}}));\n// after\nPCollectionView<X> v = slidingPco.apply(Window.into(new GlobalWindows())).apply(View.asMap());","handlingStrategy":"validation","validationCode":"if (mainWindow instanceof GlobalWindow && sideWindowFn instanceof SlidingWindows) throw new IllegalArgumentException(\"Re-window side input to GlobalWindows before sideInput\");","typeGuard":"boolean canUseSlidingSideInput(BoundedWindow w, WindowFn<?,?> fn) { return !(w instanceof GlobalWindow) || !(fn instanceof SlidingWindows); }","tryCatchPattern":null,"preventionTips":["Side inputs must be GlobalWindows or share the main input's time-windowed scheme","Never read a sliding-window view from an unwindowed main input","Standardize side-input creation through one helper that enforces windowing"],"tags":["java","apache-beam","windowing","side-input","sliding-windows"],"backgroundTag":"invalid-argument-value","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"}