{"record":{"id":"99a415e81b45e5b4","repo":"apache/beam","slug":"ontimercontext-unsupported-in-s","errorCode":null,"errorMessage":"OnTimerContext unsupported in %s","messagePattern":"OnTimerContext 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":452,"sourceCode":"    }\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) {\n      throw new UnsupportedOperationException(\n          String.format(\"Timer unsupported in %s\", getErrorContext()));\n    }\n\n    @Override\n    public RestrictionTracker<?, ?> restrictionTracker() {\n      throw new UnsupportedOperationException(","sourceCodeStart":434,"sourceCodeEnd":470,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/transforms/reflect/DoFnInvoker.java#L434-L470","documentation":"The placeholder DoFnInvoker implementation throws UnsupportedOperationException when OnTimerContext is requested. OnTimerContext is only valid while dispatching an @OnTimer callback, and the stub invoker never provides one. getErrorContext() embeds the DoFn and call-site information in the message.","triggerScenarios":"Invoking onTimerContext(...) (or onWindowExpirationContext(...) per the stub's chain of accessors) on an invoker instance that did not override that accessor — i.e. any invoker not built through DoFnInvokers' generated/reflective path.","commonSituations":"Custom runner code driving timers without a runner-provided invoker; unit tests instantiating the abstract base directly; accessing a timer context from a method that is not @OnTimer/@OnWindowExpiration.","solutions":["Build the invoker with DoFnInvokers.newInvoker/tryInvokeFor so the accessor is implemented","Request OnTimerContext only from the timer dispatch path","If writing a runner, override onTimerContext in your invoker subclass to supply the runner's timer context"],"exampleFix":"// before\nnew DoFnInvoker.BaseDoFnInvoker<T, O>(){}.onTimerContext(fn); // throws\n// after\nDoFnInvokers.tryInvokeFor(fn).onTimerContext(fn);","handlingStrategy":"validation","validationCode":"if (invoker.getClass().getSimpleName().contains(\"Unsupported\")) {\n  throw new IllegalStateException(\"Stub invoker cannot provide OnTimerContext\");\n}","typeGuard":"boolean supportsTimerContext(DoFnInvoker<?, ?> i) {\n  return i.getClass() != DoFnInvoker.BaseDoFnInvoker.class;\n}","tryCatchPattern":"try {\n  timerCtx = invoker.onTimerContext(doFn);\n} catch (UnsupportedOperationException e) {\n  throw new IllegalStateException(\"Runner does not supply OnTimerContext\", e);\n}","preventionTips":["Only dispatch timer callbacks through the invoker's invokeOnTimer path","Verify runner timer support before enabling @OnTimer DoFns","Use generated invokers, never the raw base class"],"tags":["java","apache-beam","unsupported-operation","timers"],"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"}