{"record":{"id":"9febfa4c7fb9b5f3","repo":"apache/beam","slug":"unimplemented","errorCode":null,"errorMessage":"unimplemented","messagePattern":"unimplemented","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/portability/fn_api_runner/trigger_manager.py","lineNumber":398,"sourceCode":"                          for (window, state_tag, state) in all_triplets\n                          if window not in to_be_merged] + merging_away_triplets\n    self.window_tag_values.clear()\n    for t in resulting_triplets:\n      self.window_tag_values.add(t)\n\n    # Merge also element-window pairs\n    all_elements = self.all_elements_state.read()\n    resulting_elements = [\n        (merge_result if e[0] in to_be_merged else e[0], e[1])\n        for e in all_elements\n    ]\n    self.all_elements_state.clear()\n    for e in resulting_elements:\n      self.all_elements_state.add(e)\n\n  def add_state(self, tag, value):\n    # State can only be kept in per-window context, so this is not implemented.\n    raise NotImplementedError('unimplemented')\n\n  def get_state(self, tag):\n    # State can only be kept in per-window context, so this is not implemented.\n    raise NotImplementedError('unimplemented')\n\n  def clear_state(self, tag):\n    # State can only be kept in per-window context, so this is not implemented.\n    raise NotImplementedError('unimplemented')\n\n\nclass PerWindowTriggerContext(TriggerContext):\n  def __init__(self, window, parent: FnRunnerStatefulTriggerContext):\n    self.window = window\n    self.parent = parent\n\n  def get_current_time(self):\n    return self.parent.get_current_time()\n","sourceCodeStart":380,"sourceCodeEnd":416,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/portability/fn_api_runner/trigger_manager.py#L380-L416","documentation":"`add_state` on this trigger manager raises NotImplementedError('unimplemented') because trigger state can only be kept in per-window context in the Fn API runner. The base/non-windowed TriggerContext cannot store arbitrary stateful values keyed by tag. This is a deliberate limitation, not a bug: callers must use PerWindowTriggerContext instead.","triggerScenarios":"Calling `trigger_manager.add_state(tag, value)` (via a TriggerContext that is not window-scoped) while a trigger driver tries to persist state for a trigger that requires non-window state.","commonSituations":"Custom or newly used Beam triggers (e.g. watermark-based or repeat triggers) that request state storage outside a window; running pipelines on the Python Fn API runner whose trigger spec requires generic state.","solutions":["Replace the flow with one that operates in per-window context (PerWindowTriggerContext), where state is supported","Use a trigger that does not require non-window state, or downgrade/adjust the trigger spec","Track upstream: check apache_beam releases for per-window state support of your trigger","Implement add_state/get_state/clear_state in a custom TriggerContext subclass if you control the runner wiring"],"exampleFix":"// before\nctx.add_state(tag, value)\n// after\nper_window_ctx = PerWindowTriggerContext(window, fn_runner_ctx)\nper_window_ctx.add_state(tag, value)","handlingStrategy":"try-catch","validationCode":"if type(ctx).__module__.endswith('trigger_manager') and not hasattr(ctx, 'window'):\n  raise ValueError('add_state requires a per-window TriggerContext')","typeGuard":"def is_per_window_ctx(ctx):\n  return hasattr(ctx, 'window') and hasattr(ctx, 'parent')","tryCatchPattern":"try:\n  ctx.add_state(tag, value)\nexcept NotImplementedError:\n  # fall back to per-window context or skip stateful trigger logic\n  per_window_ctx.add_state(tag, value)","preventionTips":["Only call state APIs through PerWindowTriggerContext","Check runner trigger-support docs before choosing custom triggers","Test pipelines on fn_api_runner early if you rely on trigger state"],"tags":["python","apache-beam","not-implemented","triggers"],"backgroundTag":"method-not-implemented","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"}