{"record":{"id":"688e1bca4907b09b","repo":"apache/beam","slug":"invalid-gcs-bucket-provided","errorCode":null,"errorMessage":"Invalid GCS bucket provided!","messagePattern":"Invalid GCS bucket provided!","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"sdks/python/apache_beam/runners/interactive/utils.py","lineNumber":457,"sourceCode":"def assert_bucket_exists(bucket_name: str) -> None:\n  \"\"\"Asserts whether the specified GCS bucket with the name\n  bucket_name exists.\n\n    Logs an error and raises a ValueError if the bucket does not exist.\n\n    Logs a warning if the bucket cannot be verified to exist.\n  \"\"\"\n  try:\n    from google.cloud.exceptions import ClientError\n    from google.cloud.exceptions import NotFound\n\n    from apache_beam.io.gcp.gcsio import create_storage_client\n    storage_client = create_storage_client(PipelineOptions())\n    storage_client.get_bucket(bucket_name)\n  except ClientError as e:\n    if isinstance(e, NotFound):\n      _LOGGER.error('%s bucket does not exist!', bucket_name)\n      raise ValueError('Invalid GCS bucket provided!')\n    else:\n      _LOGGER.warning(\n          'ClientError - unable to verify whether bucket %s exists',\n          bucket_name)\n  except ImportError:\n    _LOGGER.warning(\n        'ImportError - unable to verify whether bucket %s exists', bucket_name)\n\n\ndef detect_pipeline_runner(pipeline):\n  if isinstance(pipeline, Pipeline):\n    from apache_beam.runners.interactive.interactive_runner import InteractiveRunner\n    if isinstance(pipeline.runner, InteractiveRunner):\n      pipeline_runner = pipeline.runner._underlying_runner\n    else:\n      pipeline_runner = pipeline.runner\n  else:\n    pipeline_runner = None","sourceCodeStart":439,"sourceCodeEnd":475,"githubUrl":"https://github.com/apache/beam/blob/12126d8942aaf848030c478b4c6a28c6af861c66/sdks/python/apache_beam/runners/interactive/utils.py#L439-L475","documentation":"assert_bucket_exists verifies a GCS cache bucket via the Storage client; if the client raises a NotFound ClientError, the bucket does not exist and a ValueError('Invalid GCS bucket provided!') is raised so caching is not silently pointed at a missing bucket.","triggerScenarios":"Configuring interactive Beam/GCS caching with a bucket name that does not exist, is misspelled, or lives in a project the credentials cannot see; the bucket was deleted after configuration.","commonSituations":"Setting cache_destination / staging_location gcs:// paths in notebooks; typos in bucket names; wrong GOOGLE_APPLICATION_CREDENTIALS pointing at a project without the bucket.","solutions":["Create the bucket (gsutil mb or console) or correct the bucket name in the cache configuration","Verify the bucket exists: gsutil ls -b gs://<bucket>","Check credentials/project: ensure GOOGLE_APPLICATION_CREDENTIALS can see the bucket's project","Confirm the configured path is gcs://<existing-bucket>/... and not a subpath typo"],"exampleFix":"// before\nib.options.cache_destination = 'gs://my-typoed-bucket/cache'\n// after\n# ensure it exists first: gsutil mb -l us-central1 gs://my-bucket\nib.options.cache_destination = 'gs://my-bucket/cache'","handlingStrategy":"validation","validationCode":"from google.cloud import storage\ndef bucket_exists(name):\n    try:\n        storage.Client().get_bucket(name.split('gs://')[1].split('/')[0])\n        return True\n    except Exception:\n        return False\nassert bucket_exists(ib.options.cache_destination), 'bucket missing'","typeGuard":"def is_valid_gcs_path(path):\n    return isinstance(path, str) and path.startswith('gs://') and len(path.split('/')[2]) > 2","tryCatchPattern":"try:\n    configure_cache('gs://my-bucket/cache')\nexcept ValueError as e:\n    if 'Invalid GCS bucket' in str(e):\n        create_bucket_or_fix_name()","preventionTips":["Run gsutil ls -b gs://<bucket> before configuring cache destinations","Keep bucket names in one shared config to avoid typos","Ensure credentials can access the bucket's project","Create the bucket via terraform/gsutil as part of environment setup"],"tags":["gcs","configuration","google-cloud"],"backgroundTag":"resource-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"}