{"record":{"id":"0c2f9c00eeaa72ef","repo":"apache/beam","slug":"unexpected-time-domain-s","errorCode":null,"errorMessage":"Unexpected time domain: %s","messagePattern":"Unexpected time domain: (.+?)","errorType":"exception","errorClass":"Exception","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/trigger.py","lineNumber":1523,"sourceCode":"    if self.is_merging:\n      state = MergeableStateAdapter(state)\n    window = state.get_window(window_id)\n    if state.get_state(window, self.TOMBSTONE):\n      return\n\n    if time_domain in (TimeDomain.WATERMARK, TimeDomain.REAL_TIME):\n      if not self.is_merging or window in state.known_windows():\n        context = state.at(window, self.clock)\n        if self.trigger_fn.should_fire(time_domain, timestamp, window, context):\n          finished = self.trigger_fn.on_fire(timestamp, window, context)\n          yield self._output(\n              window,\n              finished,\n              state,\n              timestamp,\n              time_domain == TimeDomain.WATERMARK)\n    else:\n      raise Exception('Unexpected time domain: %s' % time_domain)\n\n  def _output(self, window, finished, state, output_watermark, maybe_ontime):\n    \"\"\"Output window and clean up if appropriate.\"\"\"\n    index = state.get_state(window, self.INDEX)\n    state.add_state(window, self.INDEX, 1)\n    if output_watermark <= window.max_timestamp():\n      nonspeculative_index = -1\n      timing = windowed_value.PaneInfoTiming.EARLY\n      if state.get_state(window, self.NONSPECULATIVE_INDEX):\n        nonspeculative_index = state.get_state(\n            window, self.NONSPECULATIVE_INDEX)\n        state.add_state(window, self.NONSPECULATIVE_INDEX, 1)\n        _LOGGER.warning(\n            'Watermark moved backwards in time '\n            'or late data moved window end forward.')\n    else:\n      nonspeculative_index = state.get_state(window, self.NONSPECULATIVE_INDEX)\n      state.add_state(window, self.NONSPECULATIVE_INDEX, 1)","sourceCodeStart":1505,"sourceCodeEnd":1541,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/trigger.py#L1505-L1541","documentation":"The streaming trigger driver's timer callback switches on time_domain and raises a bare Exception('Unexpected time domain: %s') for any domain other than WATERMARK (the only one its on-timer logic handles). REAL_TIME / DEPENDENT_REAL_TIME timers reaching this driver hit this fallback.","triggerScenarios":"A timer set with TimeDomain.REAL_TIME or TimeDomain.DEPENDENT_REAL_TIME fires and is delivered to this trigger driver's callback, which only implements the WATERMARK branch; or a corrupted/foreign time_domain value arrives from state serialization.","commonSituations":"Custom triggers or user code setting real-time timers that the built-in TriggerDriver does not support; Beam version drift where new time domains exist but this driver was not updated; tests firing timers with all domains.","solutions":["Only set TimeDomain.WATERMARK timers from trigger code, or handle real-time timers elsewhere (e.g. via the runner's timer API directly).","If you need wall-clock behavior, encode it in the watermark hold or use a runner that supports real-time timers outside TriggerDriver.","Check how the timer's time_domain was persisted; fix the code path that created a non-WATERMARK timer for this driver."],"exampleFix":"// before\nstate.set_timer(window, 'fire', TimeDomain.REAL_TIME, ts)  # driver raises on fire\n// after\nstate.set_timer(window, 'fire', TimeDomain.WATERMARK, ts)","handlingStrategy":"validation","validationCode":"from apache_beam.transforms.timeutil import TimeDomain\nassert time_domain == TimeDomain.WATERMARK, 'TriggerDriver only supports WATERMARK timers'","typeGuard":"def is_watermark_timer(td):\n    from apache_beam.transforms.timeutil import TimeDomain\n    return td == TimeDomain.WATERMARK","tryCatchPattern":"try:\n    driver.on_timer(...)\nexcept Exception as e:\n    logger.error('Timer delivery failed: %s', e)\n    raise","preventionTips":["Set only TimeDomain.WATERMARK timers from trigger code.","Handle real-time timer needs outside the built-in TriggerDriver.","Re-check timer creation paths after Beam version upgrades."],"tags":["python","apache-beam","trigger","timer","time-domain"],"backgroundTag":"unsupported-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"}