{"record":{"id":"bdb84d70b5e083d3","repo":"apache/beam","slug":"sleep-time-per-input-record-must-be-at-least-1e-3-received-r","errorCode":null,"errorMessage":"Sleep time per input record must be at least 1e-3. Received: %r","messagePattern":"Sleep time per input record must be at least 1e-3\\. Received: %r","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/testing/synthetic_pipeline.py","lineNumber":392,"sourceCode":"            'Received %r.',\n            self._initial_splitting_distribution_parameter)\n    else:\n      self._initial_splitting_distribution_parameter = 0\n    self._dynamic_splitting = (\n        'none' if (\n            'splitPointFrequencyRecords' in input_spec and\n            input_spec['splitPointFrequencyRecords'] == 0) else 'perfect')\n    if 'delayDistribution' in input_spec:\n      if input_spec['delayDistribution']['type'] != 'const':\n        raise ValueError(\n            'SyntheticSource currently only supports delay '\n            'distributions of type \\'const\\'. Received %s.',\n            input_spec['delayDistribution']['type'])\n      self._sleep_per_input_record_sec = (\n          float(input_spec['delayDistribution']['const']) / 1000)\n      if (self._sleep_per_input_record_sec and\n          self._sleep_per_input_record_sec < 1e-3):\n        raise ValueError(\n            'Sleep time per input record must be at least 1e-3.'\n            ' Received: %r',\n            self._sleep_per_input_record_sec)\n    else:\n      self._sleep_per_input_record_sec = 0\n\n    # algorithm of the generator\n    self.gen_algo = input_spec.get('algorithm', None)\n    if self.gen_algo not in (None, 'builtin', 'lcg'):\n      raise ValueError(\n          'Unknown algorithm for input_spec: %s. Supported '\n          'algorithms are \"builtin\" and \"lcg\".',\n          self.gen_algo)\n\n  @property\n  def element_size(self):\n    return self._key_size + self._value_size\n","sourceCodeStart":374,"sourceCodeEnd":410,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/testing/synthetic_pipeline.py#L374-L410","documentation":"After converting the configured per-record delay from milliseconds to seconds, SyntheticSource rejects any positive sleep time smaller than 1e-3 seconds (1 ms), since sub-millisecond sleeps are not meaningful/reliable. Only 0 (disabled) or values >= 1ms are accepted.","triggerScenarios":"Setting input_spec['delayDistribution'] = {'type': 'const', 'const': 0.5} (0.5 ms) — the converted sleep time 0.0005 is truthy but < 1e-3, raising ValueError. A const of exactly 0 or missing key is fine.","commonSituations":"Trying to configure sub-millisecond simulated latency; unit confusion (passing seconds like 0.0005 where milliseconds like 5 are expected); generating configs programmatically with fractional ms values.","solutions":["Increase the 'const' value to at least 1 (millisecond).","Set 'const' to 0 (or omit delayDistribution) to disable per-record delay.","Round/quantize generated configs so delay values are 0 or >= 1 ms."],"exampleFix":"// before\ninput_spec = {'delayDistribution': {'type': 'const', 'const': 0.5}}\n// after\ninput_spec = {'delayDistribution': {'type': 'const', 'const': 1}}","handlingStrategy":"validation","validationCode":"dd = input_spec.get('delayDistribution') or {}\nconst_ms = dd.get('const', 0)\nif const_ms and float(const_ms) / 1000 < 1e-3:\n    raise ValueError('per-record delay must be 0 or >= 1 ms')","typeGuard":"def is_valid_delay(dd) -> bool:\n    v = dd.get('const', 0)\n    return not v or float(v) / 1000 >= 1e-3","tryCatchPattern":"try:\n    source = SyntheticStep(input_spec, ...)\nexcept ValueError as e:\n    if 'Sleep time per input record' in str(e):\n        input_spec['delayDistribution']['const'] = max(input_spec['delayDistribution']['const'], 1)\n        source = SyntheticStep(input_spec, ...)\n    else:\n        raise","preventionTips":["Remember delayDistribution.const is in milliseconds; quantize to whole ms","Treat 0 as the only way to disable per-record delay","Validate all numeric config fields against their minimums before submitting the job"],"tags":["python","apache-beam","valueerror","synthetic-pipeline","value-range"],"backgroundTag":"value-out-of-range","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"}