apache/beam · error · UnsupportedOperationException
Cannot outputWindowedValue from TruncateRestriction
Error message
Cannot outputWindowedValue from TruncateRestriction
What it means
Same contract as the timestamp variant: the OutputReceiver handed to @TruncateRestriction cannot emit windowed values at all. outputWindowedValue throws UnsupportedOperationException because truncation may only yield restrictions, never elements.
Solutions
- Remove the outputWindowedValue call from @TruncateRestriction.
- Restrict all element/windowed output to @ProcessElement.
- Use a WindowedOutputReceiver only where the runner supplies one (processElement context).
Example fix
// before
@TruncateRestriction void truncate(Restriction r, WindowedOutputReceiver<Restriction> out) { out.outputWindowedValue(r, now, windows, pane); }
// after
@TruncateRestriction void truncate(Restriction r, OutputReceiver<Restriction> out) { /* no element output */ } Defensive patterns
Strategy: type-guard
Type guard
boolean isTruncateReceiver = receiver instanceof SplittableTruncateSizedRestrictionsDoFnRunner.TruncateRestrictionReceiver; // no windowed output if true
Try / catch
try { out.outputWindowedValue(r, ts, windows, pane); } catch (UnsupportedOperationException e) { LOG.error("Windowed output unsupported in truncateRestriction"); } Prevention
- Keep @TruncateRestriction free of element/windowed output
- Use restriction output only
- Consult the Splittable DoFn lifecycle docs
When it happens
Trigger: Calling outputWindowedValue(...) (with windows/pane args) on the receiver available inside a @TruncateRestriction method.
Common situations: Trying to emit to multiple windows or with a custom pane during truncation; porting code that used a full OutputReceiver/WindowedOutputReceiver into truncateRestriction.
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
- Cannot outputWithTimestamp from SplitRestriction
- Cannot outputWithTimestamp from TruncateRestriction
- RecordId unsupported in
- RecordOffset unsupported in
- Restriction unsupported in
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/a4dc3832ef19c121.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/harness/src/main/java/org/apache/beam/fn/harness/SplittableTruncateSizedRestrictionsDoFnRunner.java:935
@Override
public PipelineOptions pipelineOptions() {
return pipelineOptions;
}
@Override
public void outputWithTimestamp(RestrictionT output, Instant timestamp) {
throw new UnsupportedOperationException(
"Cannot outputWithTimestamp from TruncateRestriction");
}
@Override
public void outputWindowedValue(
RestrictionT output,
Instant timestamp,
Collection<? extends BoundedWindow> windows,
PaneInfo paneInfo) {
throw new UnsupportedOperationException(
"Cannot outputWindowedValue from TruncateRestriction");
}
}
/**
* Passes split requests downstream, by way of trySplit on the overall runner, which will split
* per window if needed.
*/
private static class SplitDelegatingFnDataReceiver<
InputT, RestrictionT extends @NonNull Object, WatermarkEstimatorStateT>
implements FnDataReceiver<
WindowedValue<KV<KV<InputT, KV<RestrictionT, WatermarkEstimatorStateT>>, Double>>>,
HandlesSplits {
private final HandlesSplits splitDelegate;
private final SplittableTruncateSizedRestrictionsDoFnRunner<
InputT, RestrictionT, ?, WatermarkEstimatorStateT, ?>
runner;View on GitHub (pinned to 12126d8942)