{"record":{"id":"12ee1aa65f4220e5","repo":"apache/beam","slug":"startbundlecontext-unsupported-in-s","errorCode":null,"errorMessage":"StartBundleContext unsupported in %s","messagePattern":"StartBundleContext unsupported in (.+?)","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java","lineNumber":439,"sourceCode":"          String.format(\"PaneInfo unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public PipelineOptions pipelineOptions() {\n      throw new UnsupportedOperationException(\n          String.format(\"PipelineOptions unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public DoFn<InputT, OutputT>.StartBundleContext startBundleContext(DoFn<InputT, OutputT> doFn) {\n      throw new UnsupportedOperationException(\n          String.format(\"StartBundleContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public DoFn<InputT, OutputT>.FinishBundleContext finishBundleContext(\n        DoFn<InputT, OutputT> doFn) {\n      throw new UnsupportedOperationException(\n          String.format(\"FinishBundleContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public DoFn<InputT, OutputT>.OnTimerContext onTimerContext(DoFn<InputT, OutputT> doFn) {\n      throw new UnsupportedOperationException(\n          String.format(\"OnTimerContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public DoFn<InputT, OutputT>.OnWindowExpirationContext onWindowExpirationContext(\n        DoFn<InputT, OutputT> doFn) {\n      throw new UnsupportedOperationException(\n          String.format(\"OnWindowExpirationContext unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public State state(String stateId, boolean alwaysFetched) {","sourceCodeStart":421,"sourceCodeEnd":457,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java#L421-L457","documentation":"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.","triggerScenarios":"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.","commonSituations":"DoFns initializing per-bundle writers in @StartBundle run through a minimal test invoker; custom execution utilities that invoke bundle lifecycle callbacks without contexts.","solutions":["Wire a startBundleContextFactory when constructing the invoker","Use the runner's standard bundle lifecycle, which supplies StartBundleContext","In tests use DoFnTester, which provides bundle contexts, instead of raw invokers","Defer output from @StartBundle to @ProcessElement if bundle-context output is unavailable"],"exampleFix":"// before\ninvoker.invokeStartBundle(doFn, ctx -> ctx.output(init)); // ctx from invoker throws\n// after\nDoFnInvoker invoker = DoFnInvokers.newInvoker(doFn,\n    DoFnInvoker.StartBundleContextProvider.boundTo(startBundleCtx));","handlingStrategy":"try-catch","validationCode":"boolean bundleCtx = invokerStartBundleProvider != null;","typeGuard":"null","tryCatchPattern":"try { invoker.startBundleContext(doFn).output(el); } catch (UnsupportedOperationException e) { /* buffer and emit in ProcessElement */ }","preventionTips":["Bind StartBundleContext provider in custom invoker setups","Use DoFnTester or real runner for bundle lifecycle tests","Avoid bundle-context output when the execution path cannot supply it"],"tags":["apache-beam","java","unsupported-operation","bundle-lifecycle"],"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"}