{"record":{"id":"2a8c89f3ff29e6b5","repo":"HumanSignal/label-studio","slug":"no-blobs-found-in-bucket-name-prefix-or-prefix","errorCode":null,"errorMessage":"No blobs found in {bucket_name}/{prefix} or prefix doesn't exist","messagePattern":"No blobs found in (.+?)/(.+?) or prefix doesn't exist","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"label_studio/io_storages/gcs/utils.py","lineNumber":105,"sourceCode":"        prefix: str = None,\n        use_glob_syntax: bool = False,\n    ):\n        logger.debug('Validating GCS connection')\n        client = cls.get_client(\n            google_application_credentials=google_application_credentials, google_project_id=google_project_id\n        )\n        logger.debug('Validating GCS bucket')\n        bucket = client.get_bucket(bucket_name)\n\n        # Dataset storages uses glob syntax and we want to add explicit checks\n        # In the future when GCS lib supports it\n        if use_glob_syntax:\n            pass\n        else:\n            if prefix:\n                blobs = list(bucket.list_blobs(prefix=prefix, max_results=1))\n                if not blobs:\n                    raise ValueError(f\"No blobs found in {bucket_name}/{prefix} or prefix doesn't exist\")\n\n    @classmethod\n    def iter_blobs(\n        cls,\n        client: gcs.Client,\n        bucket_name: str,\n        prefix: str = None,\n        regex_filter: str = None,\n        limit: int = None,\n        return_key: bool = False,\n        recursive_scan: bool = True,\n    ):\n        \"\"\"\n        Iterate files on the bucket. Optionally return limited number of files that match provided extensions\n        :param client: GCS Client obj\n        :param bucket_name: bucket name\n        :param prefix: bucket prefix\n        :param regex_filter: RegEx filter","sourceCodeStart":87,"sourceCodeEnd":123,"githubUrl":"https://github.com/HumanSignal/label-studio/blob/0b49e9b53917880baf1dd85d574fe5541a9aafb2/label_studio/io_storages/gcs/utils.py#L87-L123","documentation":"Label Studio's GCS storage raises this ValueError during connection validation when the configured bucket+prefix yields no blobs. GCS itself has no real folders, so an empty result usually means the prefix is misspelled, the bucket is empty, or the credentials lack list permission (which surfaces as an empty list here rather than an error). It is thrown by GCS.validate_connection, which is invoked when a GCS import/export storage is created or tested via the API.","triggerScenarios":"Calling validate/validate_connection on a GCSImportStorage/GCSExportStorage with (a) a prefix that matches no objects, (b) a prefix for a 'folder' that was never created (GCS folders are virtual), or (c) use_glob_syntax=False and a bucket where list_blobs(prefix=..., max_results=1) returns nothing (including permission-denied silently hiding objects in some setups).","commonSituations":"Typos in the storage prefix ('/data/tasks' vs 'data/tasks'); leading slash added by a UI copy-paste; syncing to a bucket region/project mismatch; service account without storage.objects.list; expecting glob patterns to work while use_glob_syntax is False.","solutions":["Verify the exact object key prefix in the GCP console (gsutil ls gs://<bucket>/<prefix>) and correct the storage prefix, removing any leading slash","Check that use_glob_syntax matches your intent: globs are only honored when it is True; a literal '*' in the prefix will match nothing","Confirm the service account has storage.objects.list (roles/storage.objectViewer) on the bucket","Verify GOOGLE_APPLICATION_CREDENTIALS / google_project_id point to the project that actually contains the bucket"],"exampleFix":"// before\nstorage = GCSImportStorage(bucket='my-bucket', prefix='/dataset/tasks/')  # leading slash matches nothing\n// after\nstorage = GCSImportStorage(bucket='my-bucket', prefix='dataset/tasks/')","handlingStrategy":"validation","validationCode":"from google.cloud import storage\nclient = storage.Client()\nblobs = client.list_blobs(bucket_name, prefix=prefix.strip('/'), max_results=1)\nif not any(blobs):\n    raise SystemExit(f\"Prefix gs://{bucket_name}/{prefix} has no objects — fix prefix or check IAM\")","typeGuard":"def prefix_has_objects(bucket_name: str, prefix: str) -> bool:\n    if not prefix or prefix.startswith('/'):\n        return False\n    it = client.list_blobs(bucket_name, prefix=prefix, max_results=1)\n    try:\n        next(iter(it))\n        return True\n    except StopIteration:\n        return False","tryCatchPattern":"try:\n    storage.validate_connection()\nexcept ValueError as e:\n    if 'No blobs found' in str(e):\n        logger.warning('GCS prefix empty/missing: %s', e)\n    else:\n        raise","preventionTips":["gsutil ls gs://bucket/prefix before wiring the storage","Never add a leading slash to prefixes","Match use_glob_syntax to whether your prefix contains wildcards","Grant storage.objects.list to the service account and verify with gsutil"],"tags":["gcs","storage","validation","configuration"],"backgroundTag":"storage-prefix-not-found","analyzedSha":"0b49e9b53917880baf1dd85d574fe5541a9aafb2","analyzedAt":"2026-08-29T00:39:52.578Z","schemaVersion":2},"datasetVersion":"2026-08-29T02:17:18.158Z"}