{"record":{"id":"2e6dc30a09ae9f67","repo":"apache/beam","slug":"max-read-time-seconds-must-be-0-got-r","errorCode":null,"errorMessage":"max_read_time_seconds must be > 0, got %r","messagePattern":"max_read_time_seconds must be > 0, got %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/unbounded_source.py","lineNumber":951,"sourceCode":"      checked between records, so a reader that blocks inside ``advance()`` may\n      overrun it; ``max_records_per_bundle`` is the hard backstop.\n\n  The bundle self-checkpoints as soon as either cap is reached.\n  \"\"\"\n  def __init__(\n      self,\n      source: UnboundedSource,\n      poll_interval: float = _DEFAULT_POLL_INTERVAL_SECONDS,\n      max_records_per_bundle: int = _DEFAULT_MAX_RECORDS_PER_BUNDLE,\n      max_read_time_seconds: float = _DEFAULT_MAX_READ_TIME_SECONDS):\n    if not isinstance(source, UnboundedSource):\n      raise TypeError('source must be an UnboundedSource, got %r' % (source, ))\n    if max_records_per_bundle < 1:\n      raise ValueError(\n          'max_records_per_bundle must be >= 1, got %r' %\n          (max_records_per_bundle, ))\n    if max_read_time_seconds <= 0:\n      raise ValueError(\n          'max_read_time_seconds must be > 0, got %r' %\n          (max_read_time_seconds, ))\n    if poll_interval < 0:\n      raise ValueError(\n          'poll_interval must be >= 0, got %r' % (poll_interval, ))\n    super().__init__()\n    self._source = source\n    self._poll_interval = poll_interval\n    self._max_records_per_bundle = max_records_per_bundle\n    self._max_read_time_seconds = max_read_time_seconds\n\n  def expand(self, pbegin):\n    source = self._source\n    output_coder = source.default_output_coder()\n    # The source is the SDF element used to derive the initial restriction.\n    # process() reads from the restriction, so it does not use the element\n    # directly.\n    output = (","sourceCodeStart":933,"sourceCodeEnd":969,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/unbounded_source.py#L933-L969","documentation":"max_read_time_seconds caps the wall-clock duration of a single bundle read; it must be strictly positive. The constructor raises ValueError for zero or negative values, which would immediately terminate every bundle and make progress impossible.","triggerScenarios":"Initializing the reader with max_read_time_seconds=0 or negative, typically from a mistyped config or a computation like (end - start) that evaluated to 0.","commonSituations":"Setting 0 intending 'no limit' (not valid here); unit tests passing 0 to 'disable' the cap; duration calculations in seconds returning 0 or negative due to clock issues.","solutions":["Pass a positive float, e.g. max_read_time_seconds=60.0","Validate/clamp upstream: max_read_time_seconds=max(1e-3, value)","For 'no limit' behavior, use a very large value instead of 0"],"exampleFix":"# before\nreader = Reader(source, max_read_time_seconds=0)\n# after\nreader = Reader(source, max_read_time_seconds=300.0)","handlingStrategy":"validation","validationCode":"if float(max_read_time_seconds) <= 0:\n    raise ValueError('max_read_time_seconds must be > 0')","typeGuard":null,"tryCatchPattern":"try:\n    reader = Reader(source, max_read_time_seconds=t)\nexcept ValueError:\n    reader = Reader(source, max_read_time_seconds=60.0)  # safe default","preventionTips":["Guard duration computations against clock anomalies yielding <= 0","Use large values, not 0, to mean 'effectively unlimited'","Validate duration config at load time"],"tags":["python","apache-beam","validation","config"],"backgroundTag":"invalid-config-value","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"}