{"record":{"id":"aa1f833525282ff1","repo":"apache/beam","slug":"sleep-seconds-if-received-must-be-int-but-received-r-s","errorCode":null,"errorMessage":"Sleep seconds, if received, must be int. But received: %r, %s","messagePattern":"Sleep seconds, if received, must be int\\. But received: %r, (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/testing/pipeline_verifiers.py","lineNumber":103,"sourceCode":"  Use apache_beam.io.filebasedsink to fetch file(s) from given path.\n  File checksum is a hash string computed from content of file(s).\n  \"\"\"\n  def __init__(self, file_path, expected_checksum, sleep_secs=None):\n    \"\"\"Initialize a FileChecksumMatcher object\n\n    Args:\n      file_path : A string that is the full path of output file. This path\n        can contain globs.\n      expected_checksum : A hash string that is computed from expected\n        result.\n      sleep_secs : Number of seconds to wait before verification start.\n        Extra time are given to make sure output files are ready on FS.\n    \"\"\"\n    if sleep_secs is not None:\n      if isinstance(sleep_secs, int):\n        self.sleep_secs = sleep_secs\n      else:\n        raise ValueError(\n            'Sleep seconds, if received, must be int. '\n            'But received: %r, %s' % (sleep_secs, type(sleep_secs)))\n    else:\n      self.sleep_secs = None\n\n    self.file_path = file_path\n    self.expected_checksum = expected_checksum\n\n  @retry.with_exponential_backoff(\n      num_retries=MAX_RETRIES, retry_filter=retry_on_io_error_and_server_error)\n  def _read_with_retry(self):\n    \"\"\"Read path with retry if I/O failed\"\"\"\n    read_lines = []\n    match_result = FileSystems.match([self.file_path])[0]\n    matched_path = [f.path for f in match_result.metadata_list]\n    if not matched_path:\n      raise IOError('No such file or directory: %s' % self.file_path)\n","sourceCodeStart":85,"sourceCodeEnd":121,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/testing/pipeline_verifiers.py#L85-L121","documentation":"FileBasedOutputVerifier's __init__ accepts an optional sleep_secs used to wait for output files to become ready on the filesystem. It strictly requires int (or None); any other numeric type like float raises ValueError, since fractional wait seconds are not accepted.","triggerScenarios":"Constructing the verifier with sleep_secs=1.5, a string like '10', or any non-int value parsed from pipeline options.","commonSituations":"Passing a float from config parsing (options often come as strings/floats); forgetting that even 10.0 is a float and therefore rejected.","solutions":["Pass an int literal, e.g. sleep_secs=10, or None","Convert explicitly with int() when the value comes from options/config","If fractional precision is needed, scale the unit (e.g. milliseconds) instead"],"exampleFix":"// before\nverifier = FileBasedOutputVerifier(output, sleep_secs=2.5)\n// after\nverifier = FileBasedOutputVerifier(output, sleep_secs=int(2.5)) or sleep_secs=2","handlingStrategy":"type-guard","validationCode":"if sleep_secs is not None and not isinstance(sleep_secs, int):\n    raise TypeError('sleep_secs must be int or None')","typeGuard":"def is_valid_sleep_secs(v):\n    return v is None or isinstance(v, int)","tryCatchPattern":"try:\n    verifier = FileBasedOutputVerifier(path, sleep_secs=sleep_secs)\nexcept ValueError as e:\n    _LOGGER.warning('Bad sleep_secs: %s; defaulting to None', e)\n    verifier = FileBasedOutputVerifier(path)","preventionTips":["Coerce option values with int() before constructing verifiers","Remember booleans are ints in Python — avoid passing flags","Write tests covering verifier construction with option-sourced values"],"tags":["python","type-mismatch","pipeline-verifier"],"backgroundTag":"type-mismatch","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"}