apache/hadoop · error · IOException

Error accessing Bucket %s

Error message

Error accessing Bucket %s

What it means

getBucket(bucketName) fetches bucket metadata via storage.get(); a StorageException classified NOT_FOUND returns null (mapped to 'bucket absent'), but every other StorageException is rethrown as IOException("Error accessing Bucket " + bucketName) with the original cause attached. This message therefore means the buckets.get call failed for a non-404 reason: permissions, auth, network, or API disabled.

Source

Thrown at hadoop-cloud-storage-project/hadoop-gcp/src/main/java/org/apache/hadoop/fs/gs/GoogleCloudStorage.java:197

  /**
   * Gets the bucket with the given name.
   *
   * @param bucketName name of the bucket to get
   * @return the bucket with the given name or null if bucket not found
   * @throws IOException if the bucket exists but cannot be accessed
   */
  @Nullable
  private Bucket getBucket(String bucketName) throws IOException {
    LOG.debug("getBucket({})", bucketName);
    checkArgument(!isNullOrEmpty(bucketName), "bucketName must not be null or empty");
    try {
      return storage.get(bucketName);
    } catch (StorageException e) {
      if (ErrorTypeExtractor.getErrorType(e) == ErrorTypeExtractor.ErrorType.NOT_FOUND) {
        return null;
      }
      throw new IOException("Error accessing Bucket " + bucketName, e);
    }
  }

  private static GoogleCloudStorageItemInfo createItemInfoForBlob(StorageResourceId resourceId,
      Blob blob) {
    checkArgument(resourceId != null, "resourceId must not be null");
    checkArgument(blob != null, "object must not be null");
    checkArgument(resourceId.isStorageObject(),
        "resourceId must be a StorageObject. resourceId: %s", resourceId);
    checkArgument(resourceId.getBucketName().equals(blob.getBucket()),
        "resourceId.getBucketName() must equal object.getBucket(): '%s' vs '%s'",
        resourceId.getBucketName(), blob.getBucket());
    checkArgument(resourceId.getObjectName().equals(blob.getName()),
        "resourceId.getObjectName() must equal object.getName(): '%s' vs '%s'",
        resourceId.getObjectName(), blob.getName());

    Map<String, byte[]> decodedMetadata =
        blob.getMetadata() == null ? null : decodeMetadata(blob.getMetadata());

View on GitHub (pinned to 2add963021)

Solutions

  1. Grant the service account roles/storage.objectViewer (or at least buckets.get) on the bucket and retry
  2. Verify the bucket name and project with gsutil ls gs://<bucket> using the same credentials
  3. Inspect the nested StorageException cause for its code/reason (403 PERMISSION_DENIED vs network) and address it
  4. Confirm the auth key (google.cloud.auth.service.account.json.keyfile) points at the right project
Defensive patterns

Strategy: try-catch

Try / catch

try {
  Bucket b = gcs.getBucket(bucketName);
} catch (IOException e) {
  if (e.getMessage().startsWith("Error accessing Bucket ")) {
    StorageException cause = (StorageException) e.getCause();
    if (cause.getCode() == 403) { /* grant storage.buckets.get */ }
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling getItemInfo/listStatus on a bucket-root path, or the existence check inside copy validation, when the service account lacks storage.buckets.get; using a malformed or mis-scoped bucket name; the GCS JSON API being unavailable or the project misconfigured.

Common situations: Service account granted only object-level (storage.objects.*) roles but not Reader on the bucket; typo'd bucket name in gs:// URL; private key JSON for a different project; GCS API not enabled on the project.

Related errors


AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22). Data as JSON: /api/errors/477d6fdadbf3b2d9. Report an issue: GitHub.