apache/beam · error · UnsupportedOperationException
Cannot outputWithTimestamp from TruncateRestriction
Error message
Cannot outputWithTimestamp from TruncateRestriction
What it means
The receiver provided to the @TruncateRestriction callback of a Splittable DoFn cannot emit elements with timestamps. TruncateRestriction only produces a replacement restriction when checkpointing/truncation occurs, so any element output is a model violation and throws UnsupportedOperationException.
Solutions
- Remove element output from @TruncateRestriction; only output a new restriction (or return nothing to signal no truncation).
- Move result emission into @ProcessElement where the restriction tracker permits output.
- If partial-result flushing is needed, use bundle finalization or state/timers instead.
Example fix
// before
@TruncateRestriction void truncate(@Restriction Restriction r, OutputReceiver<Restriction> out) { out.outputWithTimestamp(r, now); }
// after
@TruncateRestriction void truncate(@Restriction Restriction r, OutputReceiver<Restriction> out) { /* no output or out.output(newRestriction) */ } Defensive patterns
Strategy: type-guard
Type guard
boolean isTruncateRestrictionContext = ctx instanceof SplittableTruncateSizedRestrictionsDoFnRunner.TruncateRestrictionContext; // do not emit if true
Try / catch
try { out.outputWithTimestamp(r, ts); } catch (UnsupportedOperationException e) { LOG.error("Emitting from truncateRestriction is unsupported"); } Prevention
- Never emit elements from @TruncateRestriction
- Handle flushing of partial results in processElement/finalization
- Review Splittable DoFn contract before adding output calls
When it happens
Trigger: Calling outputWithTimestamp from inside a @TruncateRestriction method's OutputReceiver.
Common situations: Attempting to flush partial results during truncation/checkpoint; developers confusing truncateRestriction with processElement output semantics.
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 outputWindowedValue from TruncateRestriction
- Cannot outputWithTimestamp from SplitRestriction
- RecordId unsupported in
- RecordOffset unsupported in
- Restriction unsupported in
AI-assisted analysis of apache/beam@12126d8942 (2026-09-13).
Data as JSON: /api/errors/c747ccab8d0671ef.
Report an issue: GitHub.
Appendix: source
Thrown at sdks/java/harness/src/main/java/org/apache/beam/fn/harness/SplittableTruncateSizedRestrictionsDoFnRunner.java:925
@Override
@SuppressWarnings("nullness")
public Object watermarkEstimatorState() {
return getCurrentWatermarkEstimatorState();
}
@Override
public RestrictionTracker<?, ?> restrictionTracker() {
return getCurrentTracker();
}
@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.
*/View on GitHub (pinned to 12126d8942)