{"record":{"id":"50b5ba192f39b977","repo":"apache/beam","slug":"cannot-outputwithtimestamp-from-splitrestriction","errorCode":null,"errorMessage":"Cannot outputWithTimestamp from SplitRestriction","messagePattern":"Cannot outputWithTimestamp from SplitRestriction","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/harness/src/main/java/org/apache/beam/fn/harness/SplittableSplitAndSizeRestrictionsDoFnRunner.java","lineNumber":469,"sourceCode":"\n    @Override\n    public Object restriction() {\n      return getCurrentRestriction();\n    }\n\n    @Override\n    public RestrictionTracker<?, ?> restrictionTracker() {\n      return getCurrentTracker();\n    }\n\n    @Override\n    public PipelineOptions pipelineOptions() {\n      return pipelineOptions;\n    }\n\n    @Override\n    public void outputWithTimestamp(RestrictionT output, Instant timestamp) {\n      throw new UnsupportedOperationException(\"Cannot outputWithTimestamp from SplitRestriction\");\n    }\n  }\n}\n","sourceCodeStart":451,"sourceCodeEnd":473,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/harness/src/main/java/org/apache/beam/fn/harness/SplittableSplitAndSizeRestrictionsDoFnRunner.java#L451-L473","documentation":"In the Splittable DoFn sizing flow, the receiver handed to the SplitRestriction phase does not support element output. Beam's split restriction callback only produces new restrictions; emitting elements there is meaningless to the model, so outputWithTimestamp unconditionally throws UnsupportedOperationException.","triggerScenarios":"Calling outputWithTimestamp (or output) on the OutputReceiver available inside a @SplitRestriction method of a Splittable DoFn.","commonSituations":"Developers migrating a DoFn to Splittable DoFn try to emit results during splitRestriction instead of only yielding restrictions; copy-paste of output calls from processElement.","solutions":["Remove any output calls from @SplitRestriction; it must only yield new restrictions via OutputReceiver.output(restriction).","Emit actual elements only in @ProcessElement using the ProcessElements/ restriction tracker receiver.","Refactor logic so splitRestriction performs no side effects other than restriction output."],"exampleFix":"// before\n@SplitRestriction void split(Restriction r, OutputReceiver<Restriction> out) { out.outputWithTimestamp(r, now); }\n// after\n@SplitRestriction void split(Restriction r, OutputReceiver<Restriction> out) { out.output(r); }","handlingStrategy":"type-guard","validationCode":null,"typeGuard":"boolean isSplitRestrictionReceiver = receiver instanceof SplittableSplitAndSizeRestrictionsDoFnRunner.SplitRestrictionReceiver; // do not emit if true","tryCatchPattern":"try { out.outputWithTimestamp(r, ts); } catch (UnsupportedOperationException e) { LOG.error(\"Emitting from splitRestriction is unsupported\"); }","preventionTips":["Never emit elements from @SplitRestriction","Only call out.output(restriction) there","Emit user elements exclusively in @ProcessElement"],"tags":["apache-beam","splittable-dofn","unsupported-operation"],"backgroundTag":"unsupported-operation","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-20T03:17:13.778Z"}