{"record":{"id":"d6620dbc7169edd8","repo":"apache/beam","slug":"window-fn-s-does-not-have-a-determanistic-coder-s","errorCode":null,"errorMessage":"window fn (%s) does not have a determanistic coder (%s)","messagePattern":"window fn \\((.+?)\\) does not have a determanistic coder \\((.+?)\\)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/core.py","lineNumber":3894,"sourceCode":"      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)\n\n  def __repr__(self):\n    return \"Windowing(%s, %s, %s, %s, %s)\" % (","sourceCodeStart":3876,"sourceCodeEnd":3912,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/core.py#L3876-L3912","documentation":"Raised in the Windowing constructor when the provided window function's window coder reports is_deterministic() == False. Beam serializes window objects (e.g. as group-by keys during shuffle), and a non-deterministic coder would produce inconsistent bytes for equal windows, breaking correctness. Note the message contains the long-standing typo 'determanistic'.","triggerScenarios":"Passing a custom WindowFn whose get_window_coder() returns a non-deterministic coder (e.g. a coder over unsorted iterables or float fields) into beam.WindowInto or the Windowing transform.","commonSituations":"Custom IntervalWindow/GlobalWindow subclasses coded with an inferred coder based on floats or dicts; third-party window functions; coders affected by Python hash randomization for sets.","solutions":["Implement a deterministic custom Coder for your window type (stable byte encoding for equal windows) and return it from get_window_coder().","Replace float fields with int/Decimal or fixed-point representations in the window object.","Sort any collection fields before encoding.","Prefer built-in window functions (GlobalWindows, FixedWindows, SlidingWindows, Sessions) which ship deterministic coders."],"exampleFix":"// before\nclass MyWindow:  # coder inferred from float fields -> non-deterministic\n  ...\npc | beam.WindowInto(MyWindowFn())\n// after\nclass MyWindowFn(UserDefinedWindowFn):\n  def get_window_coder(self):\n    return DeterministicMyWindowCoder()  # stable encoding\npc | beam.WindowInto(MyWindowFn())","handlingStrategy":"validation","validationCode":"coder = windowfn.get_window_coder()\nassert coder.is_deterministic(), f'{windowfn} coder {coder} is not deterministic'","typeGuard":null,"tryCatchPattern":"try:\n    pc | beam.WindowInto(custom_windowfn)\nexcept ValueError as e:\n    log.error('Window coder issue: %s', e)","preventionTips":["Implement deterministic coders for custom window types","Avoid float fields in window objects","Prefer built-in WindowFn classes","Sort collection fields before encoding"],"tags":["python","apache-beam","windowing","coder","determinism"],"backgroundTag":"invalid-argument-value","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-15T02:17:10.978Z"}