{"record":{"id":"a70ed0c88e25e578","repo":"apache/beam","slug":"window-coder-should-not-be-none","errorCode":null,"errorMessage":"window_coder should not be None","messagePattern":"window_coder should not be None","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/transforms/util.py","lineNumber":1437,"sourceCode":"\nclass _IdentityWindowFn(NonMergingWindowFn):\n  \"\"\"Windowing function that preserves existing windows.\n\n  To be used internally with the Reshuffle transform.\n  Will raise an exception when used after DoFns that return TimestampedValue\n  elements.\n  \"\"\"\n  def __init__(self, window_coder):\n    \"\"\"Create a new WindowFn with compatible coder.\n    To be applied to PCollections with windows that are compatible with the\n    given coder.\n\n    Arguments:\n      window_coder: coders.Coder object to be used on windows.\n    \"\"\"\n    super().__init__()\n    if window_coder is None:\n      raise ValueError('window_coder should not be None')\n    self._window_coder = window_coder\n\n  def assign(self, assign_context):\n    if assign_context.window is None:\n      raise ValueError(\n          'assign_context.window should not be None. '\n          'This might be due to a DoFn returning a TimestampedValue.')\n    return [assign_context.window]\n\n  def get_window_coder(self):\n    return self._window_coder\n\n\ndef reify_metadata_default_window(\n    element, timestamp=DoFn.TimestampParam, pane_info=DoFn.PaneInfoParam):\n  key, value = element\n  if timestamp == window.MIN_TIMESTAMP:\n    timestamp = None","sourceCodeStart":1419,"sourceCodeEnd":1455,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/transforms/util.py#L1419-L1455","documentation":"The _ReassignWindowsDoFn's window-coder wrapper requires a coders.Coder for windows; constructing it with window_coder=None raises ValueError because windowing assignment cannot serialize/identify windows without a coder.","triggerScenarios":"Internally instantiating the reassign-windows helper (or subclassing it) with window_coder=None — typically when a custom Windowing/WindowFn plumbing path forgets to fetch get_window_coder().","commonSituations":"Custom transform code that wires a WindowFn but skips its window coder; refactors that drop the coder argument; unit-testing the DoFn directly with None.","solutions":["Pass a real window coder, usually windowing.get_window_coder(pcoll.windowing) or window_fn.get_window_coder()","Ensure the pipeline's windowing strategy is set before the transform expands","In tests, construct the coder explicitly (e.g. coders.IntervalWindowCoder) instead of None"],"exampleFix":"// before\nhelper = _ReassignWindowsDoFn._WindowCoderPlaceholder(window_coder=None)\n// after\ncoder = pcoll.windowing.windowfn.get_window_coder()\nhelper = _ReassignWindowsDoFn._WindowCoderPlaceholder(window_coder=coder)","handlingStrategy":"validation","validationCode":"if window_coder is None:\n    raise ValueError('window_coder required')","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Fetch coders via window_fn.get_window_coder()","Set the PCollection's windowing strategy before constructing helpers","Construct coders explicitly in tests (coders.IntervalWindowCoder)"],"tags":["python","apache-beam","windowing","coder","constructor"],"backgroundTag":"null-argument","analyzedSha":"12126d8942aaf848030c478b4c6a28c6af861c66","analyzedAt":"2026-09-13T01:50:10.254Z","contentChangedAt":"2026-09-13T01:50:10.254Z","schemaVersion":2},"datasetVersion":"2026-09-14T21:17:11.552Z"}