{"record":{"id":"962920a54980beeb","repo":"apache/beam","slug":"s-is-not-permitted-for-user-timers","errorCode":null,"errorMessage":"%s is not permitted for user timers","messagePattern":"(.+?) is not permitted for user timers","errorType":"validation","errorClass":"java.lang.IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/ParDoTranslation.java","lineNumber":746,"sourceCode":"      TimerSpec timer,\n      SdkComponents components,\n      Coder<?> keyCoder,\n      Coder<BoundedWindow> windowCoder) {\n    return RunnerApi.TimerFamilySpec.newBuilder()\n        .setTimeDomain(translateTimeDomain(timer.getTimeDomain()))\n        .setTimerFamilyCoderId(\n            registerCoderOrThrow(components, Timer.Coder.of(keyCoder, windowCoder)))\n        .build();\n  }\n\n  public static RunnerApi.TimeDomain.Enum translateTimeDomain(TimeDomain timeDomain) {\n    switch (timeDomain) {\n      case EVENT_TIME:\n        return RunnerApi.TimeDomain.Enum.EVENT_TIME;\n      case PROCESSING_TIME:\n        return RunnerApi.TimeDomain.Enum.PROCESSING_TIME;\n      case SYNCHRONIZED_PROCESSING_TIME:\n        throw new IllegalArgumentException(\n            String.format(\n                \"%s is not permitted for user timers\",\n                TimeDomain.SYNCHRONIZED_PROCESSING_TIME.name()));\n      default:\n        throw new IllegalArgumentException(\"Unknown time domain\");\n    }\n  }\n\n  public static FunctionSpec translateDoFn(\n      DoFn<?, ?> fn,\n      TupleTag<?> tag,\n      Map<String, PCollectionView<?>> sideInputMapping,\n      DoFnSchemaInformation doFnSchemaInformation,\n      SdkComponents components) {\n    return FunctionSpec.newBuilder()\n        .setUrn(CUSTOM_JAVA_DO_FN_URN)\n        .setPayload(\n            ByteString.copyFrom(","sourceCodeStart":728,"sourceCodeEnd":764,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/java/core/src/main/java/org/apache/beam/sdk/util/construction/ParDoTranslation.java#L728-L764","documentation":"Beam's user-facing Timer API supports EVENT_TIME and PROCESSING_TIME domains only. timerFamilyTimeDomainToProto maps the Java TimeDomain enum to the proto enum, and SYNCHRONIZED_PROCESSING_TIME — an internal domain used by runners/test streams — is explicitly rejected for user timers with this IllegalArgumentException.","triggerScenarios":"Defining or translating a @Timer whose TimeDomain parameter is TimeDomain.SYNCHRONIZED_PROCESSING_TIME (e.g. via TimerSpec/@TimerFamily or a DoFn signature) so translateTimerFamilySpec hits the forbidden case.","commonSituations":"Copy-pasting timer signatures from runner internals/test-stream code; constructing a TimerSpec programmatically with the wrong TimeDomain constant; migrating code that used internal timer APIs.","solutions":["Change the timer to TimeDomain.EVENT_TIME or TimeDomain.PROCESSING_TIME","Only use SYNCHRONIZED_PROCESSING_TIME in runner/test-stream internals, not user DoFn timers","Review the @TimerFamily signature and the TimeDomain import used in the DoFn"],"exampleFix":"// before\n@TimerFamily(\"alarm\") Timer family; // declared with TimeDomain.SYNCHRONIZED_PROCESSING_TIME\n// after\ntimer = dofnTimer.withTimeDomain(TimeDomain.EVENT_TIME); // or PROCESSING_TIME","handlingStrategy":"validation","validationCode":"if (timeDomain == TimeDomain.SYNCHRONIZED_PROCESSING_TIME) throw new IllegalArgumentException(\"SYNCHRONIZED_PROCESSING_TIME not allowed for user timers\");","typeGuard":"boolean isUserTimerDomain(TimeDomain d) { return d == TimeDomain.EVENT_TIME || d == TimeDomain.PROCESSING_TIME; }","tryCatchPattern":"try { String proto = ParDoTranslation.timerFamilyTimeDomainToProto(timeDomain); } catch (IllegalArgumentException e) { /* switch to EVENT_TIME */ }","preventionTips":["Only declare timers with EVENT_TIME or PROCESSING_TIME","Never copy TimeDomain constants from runner/test-stream internals","Document allowed domains on custom TimerSpec builders"],"tags":["java","apache-beam","timers","pardo"],"backgroundTag":"invalid-enum-value","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"}