apache/beam · error · UnsupportedOperationException
Cannot access sideInput in non-window observing context.
Error message
Cannot access sideInput in non-window observing context.
What it means
NonWindowObservingProcessBundleContextBase.sideInput(String tagId) throws UnsupportedOperationException because side inputs require a bound window to resolve a view, and this context serves a method that was not declared window-observing. The harness therefore refuses to resolve side inputs in this context.
Source
Thrown at sdks/java/harness/src/main/java/org/apache/beam/fn/harness/FnApiDoFnRunner.java:1972
@Override
public CausedByDrain causedByDrain(DoFn<InputT, OutputT> doFn) {
return currentElement.causedByDrain();
}
}
/** Provides base arguments for a {@link DoFnInvoker} for a non-window observing method. */
private abstract class NonWindowObservingProcessBundleContextBase
extends ProcessBundleContextBase {
@Override
public BoundedWindow window() {
throw new UnsupportedOperationException(
"Cannot access window in non-window observing context.");
}
@Override
public Object sideInput(String tagId) {
throw new UnsupportedOperationException(
"Cannot access sideInput in non-window observing context.");
}
@Override
public <T> T sideInput(PCollectionView<T> view) {
throw new UnsupportedOperationException(
"Cannot access sideInput in non-window observing context.");
}
@Override
public State state(String stateId, boolean alwaysFetched) {
throw new UnsupportedOperationException(
"Cannot access state in non-window observing context.");
}
@Override
public org.apache.beam.sdk.state.Timer timer(String timerId) {
throw new UnsupportedOperationException(View on GitHub (pinned to 12126d8942)
Solutions
- Add a BoundedWindow parameter to the @ProcessElement signature so the window-observing context (which implements sideInput) is used.
- Use the view-based c.sideInput(PCollectionView) only inside window-observing @ProcessElement methods.
- If the side input is window-independent, read it via a different mechanism (e.g., pass the data as the main input or a broadcast/readied view computed outside the DoFn).
Example fix
// before
@ProcessElement
public void processElement(ProcessContext c) {
Object v = c.sideInput("myTag"); // throws
}
// after
@ProcessElement
public void processElement(ProcessContext c, BoundedWindow window) {
MyView v = c.sideInput(myView);
} Defensive patterns
Strategy: validation
Validate before calling
// Resolve side inputs only in window-observing @ProcessElement methods:
boolean canReadSideInput = Arrays.stream(dofn.getClass().getDeclaredMethods())
.filter(m -> m.isAnnotationPresent(ProcessElement.class))
.anyMatch(m -> Arrays.stream(m.getParameterTypes()).anyMatch(BoundedWindow.class::isAssignableFrom)); Type guard
BoundedWindow requireWindow(DoFn.ProcessContext ctx) {
BoundedWindow w = ctx instanceof FnApiDoFnRunner.ProcessBundleContextBase
? null : null;
return w; // null => non-window-observing context, side input unavailable
} Try / catch
try {
V v = c.sideInput(view);
} catch (UnsupportedOperationException e) {
throw new IllegalStateException("sideInput requires a window-observing @ProcessElement (add BoundedWindow param)", e);
} Prevention
- Add BoundedWindow to @ProcessElement before using any sideInput API.
- Never read side inputs in @StartBundle/@FinishBundle.
- Prefer the sideInput(PCollectionView) overload over raw tag ids and keep signatures consistent.
When it happens
Trigger: Calling ProcessContext.sideInput(tagId) (string overload) from a @ProcessElement method without a BoundedWindow parameter, or from @StartBundle/@FinishBundle, where no window is available to index the side input view.
Common situations: Reading a side input in a non-windowed DoFn after refactoring; using the tag-based sideInput API introduced with newer Beam versions from lifecycle methods; forgetting the BoundedWindow parameter after migrating code.
Understand the failure class
Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.
Related errors
- SideInput unsupported in ${context}
- calling getSideInput() with unknown view
- Cannot access window in non-window observing context.
- Cannot access state in non-window observing context.
- Cannot access timer in non-window observing context.
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/059f59b69dff3bc5.
Report an issue: GitHub.