{"record":{"id":"a7062dc038bfbbe0","repo":"apache/beam","slug":"finishbundlecontext-unsupported-in-s","errorCode":null,"errorMessage":"FinishBundleContext unsupported in %s","messagePattern":"FinishBundleContext 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":445,"sourceCode":"          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) {\n      throw new UnsupportedOperationException(\n          String.format(\"State unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public Timer timer(String timerId) {","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java#L427-L463","documentation":"DoFnInvoker's anonymous 'unsupported invoker' base implementation throws UnsupportedOperationException for every context accessor. Asking it for a FinishBundleContext means the code path is being driven by the stub invoker rather than a real (generated or reflective) invoker bound to a runner. The message is formatted with getErrorContext(), which names the DoFn and call context that was being accessed.","triggerScenarios":"Calling a method like doFnInvoker.onTimerContext(doFn) (or any other accessor on the same class) when the invoker instance is the 'unsupported' placeholder returned by the base class instead of a concrete invoker created via DoFnInvokers.","commonSituations":"Runner or testing harness code that constructs an invoker base without overriding the accessor; a custom runner reusing DoFnInvoker internals incorrectly; calling context accessors outside the lifecycle method that legitimately provides them (e.g. requesting a FinishBundleContext during processElement).","solutions":["Obtain the invoker via DoFnInvokers.tryInvokeFor / newInvoker so the generated or reflective implementation overrides the accessor you need","Only access the context type that matches the current lifecycle phase (FinishBundleContext only inside @FinishBundle)","Check which runner/test harness supplied the invoker; implement or wire the missing accessor override"],"exampleFix":"// before\nDoFnInvoker<BaseDoFn> invoker = new DoFnInvoker.BaseDoFnInvoker<BaseDoFn, BaseDoFn>() {};\ninvoker.finishBundleContext(fn); // throws\n// after\nDoFnInvoker<BaseDoFn> invoker = DoFnInvokers.tryInvokeFor(fn);\n// use the context only inside the @FinishBundle lifecycle invocation","handlingStrategy":"validation","validationCode":"if (!(invoker instanceof DoFnInvoker.BaseDoFnInvoker)) {\n  // safe to request lifecycle contexts\n}","typeGuard":"boolean isRealInvoker(DoFnInvoker<?, ?> i) {\n  return !(i instanceof DoFnInvoker.BaseDoFnInvoker);\n}","tryCatchPattern":"try {\n  ctx = invoker.finishBundleContext(doFn);\n} catch (UnsupportedOperationException e) {\n  log.warn(\"Context unavailable: {}\", e.getMessage());\n  return;\n}","preventionTips":["Always create invokers via DoFnInvokers.tryInvokeFor/newInvoker","Match context access to the lifecycle phase the DoFn is currently in","In runner code, override every accessor you expect callers to use"],"tags":["java","apache-beam","unsupported-operation","dofn"],"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"}