{"record":{"id":"fb6e4807021ca8d2","repo":"apache/beam","slug":"accumulation-mode-must-be-provided-for-non-trivial-triggers","errorCode":null,"errorMessage":"accumulation_mode must be provided for non-trivial triggers","messagePattern":"accumulation_mode must be provided for non-trivial triggers","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/core.py","lineNumber":3891,"sourceCode":"      allowed_lateness: Maximum delay in seconds after end of window\n        allowed for any late data to be processed without being discarded\n        directly.\n      environment_id: Environment where the current window_fn should be\n        applied in.\n    \"\"\"\n    global AccumulationMode, DefaultTrigger  # pylint: disable=global-variable-not-assigned\n    # pylint: disable=wrong-import-order, wrong-import-position\n    from apache_beam.transforms.trigger import AccumulationMode\n    from apache_beam.transforms.trigger import DefaultTrigger\n\n    # pylint: enable=wrong-import-order, wrong-import-position\n    if triggerfn is None:\n      triggerfn = DefaultTrigger()\n    if accumulation_mode is None:\n      if triggerfn == DefaultTrigger():\n        accumulation_mode = AccumulationMode.DISCARDING\n      else:\n        raise ValueError(\n            'accumulation_mode must be provided for non-trivial triggers')\n    if not windowfn.get_window_coder().is_deterministic():\n      raise ValueError(\n          'window fn (%s) does not have a determanistic coder (%s)' %\n          (windowfn, windowfn.get_window_coder()))\n    self.windowfn = windowfn\n    self.triggerfn = triggerfn\n    self.accumulation_mode = accumulation_mode\n    self.allowed_lateness = Duration.of(allowed_lateness)\n    self.environment_id = environment_id\n    self.timestamp_combiner = (\n        timestamp_combiner or TimestampCombiner.OUTPUT_AT_EOW)\n    self._is_default = (\n        self.windowfn == GlobalWindows() and\n        self.triggerfn == DefaultTrigger() and\n        self.accumulation_mode == AccumulationMode.DISCARDING and\n        self.timestamp_combiner == TimestampCombiner.OUTPUT_AT_EOW and\n        self.allowed_lateness == 0)","sourceCodeStart":3873,"sourceCodeEnd":3909,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/core.py#L3873-L3909","documentation":"Raised in the WindowInto/Windowing constructor when a custom (non-default) trigger is supplied but accumulation_mode is not specified. Beam must know whether fired panes should accumulate or discard contents when a trigger fires multiple times; this is only inferable for the DefaultTrigger (which defaults to DISCARDING).","triggerScenarios":"beam.WindowInto(beam.trigger.AfterCount(10)) or any custom trigger (AfterWatermark, AfterProcessingTime, Repeatedly, etc.) without accumulation_mode=..., e.g. beam.WindowInto(AfterWatermark(), windowfn=...).","commonSituations":"Upgrading Beam where triggers were used without accumulation mode; copying examples of custom triggers that omit the parameter; adding a trigger to existing WindowInto code that previously used defaults.","solutions":["Add accumulation_mode=beam.trigger.AccumulationMode.DISCARDING (or ACCUMULATING) to the WindowInto call.","Use ACCUMULATING if later panes should contain all data since window start; DISCARDING if only new data.","If no custom trigger is actually needed, remove the trigger argument so the default applies."],"exampleFix":"// before\npc | beam.WindowInto(beam.trigger.AfterCount(5))\n// after\npc | beam.WindowInto(beam.trigger.AfterCount(5), accumulation_mode=beam.trigger.AccumulationMode.ACCUMULATING)","handlingStrategy":"validation","validationCode":"trigger = beam.trigger.AfterCount(5)\nassert accumulation_mode is not None or isinstance(trigger, beam.trigger.DefaultTrigger), 'set accumulation_mode with custom triggers'","typeGuard":null,"tryCatchPattern":"try:\n    pc | beam.WindowInto(trigger, accumulation_mode=mode)\nexcept ValueError as e:\n    log.error('Windowing config error: %s', e)","preventionTips":["Always pass accumulation_mode explicitly when using any trigger","Decide ACCUMULATING vs DISCARDING semantics up front","Watch for missing accumulation_mode when upgrading Beam or copying examples"],"tags":["python","apache-beam","windowing","triggers"],"backgroundTag":"missing-required-argument","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"}