apache/beam · error · UnsupportedOperationException

StartBundleContext unsupported in

Error message

StartBundleContext unsupported in %s

What it means

startBundleContext() throws UnsupportedOperationException because this invoker has no StartBundleContext provider bound. This context allows @StartBundle methods to output elements for the bundle. The error context in the message names the unsupported invoker.

Solutions

  1. Wire a startBundleContextFactory when constructing the invoker
  2. Use the runner's standard bundle lifecycle, which supplies StartBundleContext
  3. In tests use DoFnTester, which provides bundle contexts, instead of raw invokers
  4. Defer output from @StartBundle to @ProcessElement if bundle-context output is unavailable

Example fix

// before
invoker.invokeStartBundle(doFn, ctx -> ctx.output(init)); // ctx from invoker throws
// after
DoFnInvoker invoker = DoFnInvokers.newInvoker(doFn,
    DoFnInvoker.StartBundleContextProvider.boundTo(startBundleCtx));
Defensive patterns

Strategy: try-catch

Validate before calling

boolean bundleCtx = invokerStartBundleProvider != null;

Type guard

null

Try / catch

try { invoker.startBundleContext(doFn).output(el); } catch (UnsupportedOperationException e) { /* buffer and emit in ProcessElement */ }

Prevention

When it happens

Trigger: Calling startBundleContext(DoFn) on a DelegatingDoFnInvoker or generated invoker without a startBundleContextFactory; @StartBundle code calling ctx.output(...) when the harness didn't wire a bundle context.

Common situations: DoFns initializing per-bundle writers in @StartBundle run through a minimal test invoker; custom execution utilities that invoke bundle lifecycle callbacks without contexts.

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


AI-assisted analysis of apache/beam@12126d8942 (2026-09-13). Data as JSON: /api/errors/12ee1aa65f4220e5. Report an issue: GitHub.

Appendix: source

Thrown at sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java:439

          String.format("PaneInfo unsupported in %s", getErrorContext()));
    }

    @Override
    public PipelineOptions pipelineOptions() {
      throw new UnsupportedOperationException(
          String.format("PipelineOptions unsupported in %s", getErrorContext()));
    }

    @Override
    public DoFn<InputT, OutputT>.StartBundleContext startBundleContext(DoFn<InputT, OutputT> doFn) {
      throw new UnsupportedOperationException(
          String.format("StartBundleContext unsupported in %s", getErrorContext()));
    }

    @Override
    public DoFn<InputT, OutputT>.FinishBundleContext finishBundleContext(
        DoFn<InputT, OutputT> doFn) {
      throw new UnsupportedOperationException(
          String.format("FinishBundleContext unsupported in %s", getErrorContext()));
    }

    @Override
    public DoFn<InputT, OutputT>.OnTimerContext onTimerContext(DoFn<InputT, OutputT> doFn) {
      throw new UnsupportedOperationException(
          String.format("OnTimerContext unsupported in %s", getErrorContext()));
    }

    @Override
    public DoFn<InputT, OutputT>.OnWindowExpirationContext onWindowExpirationContext(
        DoFn<InputT, OutputT> doFn) {
      throw new UnsupportedOperationException(
          String.format("OnWindowExpirationContext unsupported in %s", getErrorContext()));
    }

    @Override
    public State state(String stateId, boolean alwaysFetched) {

View on GitHub (pinned to 12126d8942)