{"record":{"id":"020ecb581eff4c9b","repo":"apache/beam","slug":"no-files-found-based-on-the-file-pattern-s","errorCode":null,"errorMessage":"No files found based on the file pattern %s","messagePattern":"No files found based on the file pattern (.+?)","errorType":"exception","errorClass":"IOError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/io/filebasedsource.py","lineNumber":191,"sourceCode":"\n    return self._concat_source\n\n  def open_file(self, file_name):\n    return FileSystems.open(\n        file_name,\n        'application/octet-stream',\n        compression_type=self._compression_type)\n\n  @check_accessible(['_pattern'])\n  def _validate(self):\n    \"\"\"Validate if there are actual files in the specified glob pattern\n    \"\"\"\n    pattern = self._pattern.get()\n\n    # Limit the responses as we only want to check if something exists\n    match_result = FileSystems.match([pattern], limits=[1])[0]\n    if len(match_result.metadata_list) <= 0:\n      raise IOError('No files found based on the file pattern %s' % pattern)\n\n  def split(\n      self, desired_bundle_size=None, start_position=None, stop_position=None):\n    return self._get_concat_source().split(\n        desired_bundle_size=desired_bundle_size,\n        start_position=start_position,\n        stop_position=stop_position)\n\n  def estimate_size(self):\n    return self._get_concat_source().estimate_size()\n\n  def read(self, range_tracker):\n    return self._get_concat_source().read(range_tracker)\n\n  def get_range_tracker(self, start_position, stop_position):\n    return self._get_concat_source().get_range_tracker(\n        start_position, stop_position)\n","sourceCodeStart":173,"sourceCodeEnd":209,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/io/filebasedsource.py#L173-L209","documentation":"Raised as an IOError by FileBasedSource._validate when a FileSystems.match() call against the user-supplied glob pattern returns zero metadata entries. Beam validates at pipeline-construction time that the pattern actually matches at least one file before building split sources. It fails fast so a bad pattern is caught before the job runs.","triggerScenarios":"Passing a glob (e.g. 'gs://bucket/data/*.json') or literal path to ReadFromText/ReadFromAvro/etc. when no file exists at that location, the bucket/prefix is misspelled, the files were deleted/moved, or credentials restrict listing so the match returns nothing.","commonSituations":"Typos in bucket names or prefixes; reading yesterday's partition files that haven't been written yet; wrong GCS/AWS credentials limiting list results; using a pattern without wildcards pointing at a single missing file; Windows path separators in a pattern.","solutions":["Verify the pattern matches by running apache_beam.io.filesystems.FileSystems.match([pattern]) locally and inspecting the result","List the actual location (gsutil ls / aws s3 ls) to confirm files exist and correct the prefix or glob","Check that credentials for the filesystem are set so listing is permitted","If zero files is legitimately possible, use the empty_match_treatment/allow_empty_match option of the fileio transforms instead of the classic IO"],"exampleFix":"// before\nlines = p | 'read' >> beam.io.ReadFromText('gs://my-bucket/data/2026-09-1*.json')\n// after\n# verify pattern first\nfrom apache_beam.io.filesystems import FileSystems\nassert FileSystems.match(['gs://my-bucket/data/2026-09-1*.json'])[0].metadata_list\nlines = p | 'read' >> beam.io.ReadFromText('gs://my-bucket/data/2026-09-1*.json')","handlingStrategy":"validation","validationCode":"from apache_beam.io.filesystems import FileSystems\nresult = FileSystems.match([pattern], limits=[1])[0]\nif not result.metadata_list:\n    raise FileNotFoundError(f'Pattern matches no files: {pattern}')","typeGuard":"def pattern_matches_files(pattern: str) -> bool:\n    from apache_beam.io.filesystems import FileSystems\n    return len(FileSystems.match([pattern], limits=[1])[0].metadata_list) > 0","tryCatchPattern":"import errno\ntry:\n    lines = p | beam.io.ReadFromText(pattern)\nexcept IOError as e:\n    if e.errno == errno.ENOENT or 'No files found' in str(e):\n        logging.warning('No files for %s; using empty fallback', pattern)\n    else:\n        raise","preventionTips":["Test glob patterns with FileSystems.match before submitting the pipeline","Use explicit, versioned paths (dated prefixes) and confirm they exist upstream","Ensure filesystem credentials are configured in the runner environment","Prefer fileio transforms with empty_match_treatment when empty inputs are legal"],"tags":["io","filesystem","gcs","file-pattern"],"backgroundTag":"file-not-found","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"}