{"record":{"id":"faf2d542da4a4122","repo":"apache/beam","slug":"watch-requires-a-poll-interval","errorCode":null,"errorMessage":"Watch requires a poll_interval","messagePattern":"Watch requires a poll_interval","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/watch.py","lineNumber":858,"sourceCode":"      Widen it for a source whose outputs arrive out of order, at the cost of a\n      larger state. Ignored unless ``timestamp_cursor`` is set; defaults to\n      zero.\n    now_fn: clock used for termination decisions; tests can inject one.\n  \"\"\"\n  def __init__(\n      self,\n      poll_fn: Callable[[Any], PollResult],\n      poll_interval,\n      termination: Optional[TerminationCondition] = None,\n      output_coder: Optional[Coder] = None,\n      output_key_fn: Optional[Callable[[Any], Any]] = None,\n      output_key_coder: Optional[Coder] = None,\n      timestamp_cursor: bool = False,\n      allowed_lateness=0,\n      now_fn: Optional[Callable[[], float]] = None):\n    super().__init__()\n    if poll_interval is None:\n      raise ValueError('Watch requires a poll_interval')\n    allowed_lateness = _as_duration(allowed_lateness)\n    if allowed_lateness < Duration(0):\n      raise ValueError(\n          'Watch allowed_lateness must not be negative, got %s' %\n          allowed_lateness)\n    self._poll_fn = poll_fn\n    self._poll_interval = _as_duration(poll_interval)\n    self._termination = termination or never()\n    self._output_coder = output_coder\n    self._output_key_fn = output_key_fn\n    self._output_key_coder = output_key_coder\n    self._timestamp_cursor = timestamp_cursor\n    self._allowed_lateness = allowed_lateness\n    self._now = now_fn\n\n  def expand(self, pcoll):\n    output_coder = self._output_coder\n    if output_coder is None and isinstance(self._poll_fn, PollFn):","sourceCodeStart":840,"sourceCodeEnd":876,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/watch.py#L840-L876","documentation":"beam.Watch's underlying transform requires an explicit poll_interval (how long to wait between calls to the poll function). Since no sensible default exists (it depends on the external source), __init__ raises ValueError when poll_interval is None.","triggerScenarios":"Constructing beam.Watch (or _Pollers/wrapper) without passing poll_interval, e.g. beam.Watch(source) with only source/output_fn arguments and no poll_interval keyword.","commonSituations":"Users forgetting that unlike some polling utilities Watch has no default poll interval; copying old examples where poll_interval was optional; passing None explicitly from a config value that failed to load.","solutions":["Pass poll_interval explicitly, e.g. beam.Watch(source, event_time_fn=..., poll_interval=30)","Check your configuration loading — ensure the interval config key is populated before constructing the transform","Use a sane default like poll_interval=30 (seconds) for external-system polling"],"exampleFix":"// before\nresult = (p | beam.Watch(poll_fn))\n// after\nresult = (p | beam.Watch(poll_fn, poll_interval=30))","handlingStrategy":"validation","validationCode":"if poll_interval is None:\n    raise ValueError('poll_interval is required for Watch')","typeGuard":null,"tryCatchPattern":"try:\n    step = beam.Watch(poll_fn, poll_interval=interval)\nexcept ValueError:\n    step = beam.Watch(poll_fn, poll_interval=30)","preventionTips":["Always pass poll_interval explicitly when using Watch","Validate pipeline config keys (interval settings) before constructing transforms","Copy parameter lists from the current Beam docs, not stale examples"],"tags":["python","apache-beam","missing-argument","watch-io"],"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-14T16:17:12.679Z"}