Skip to content
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
This repository was archived by the owner on Apr 2, 2026. It is now read-only.

Java Storage NIO: FileSystemProvider::checkAccess fails on '/' with StorageException #1062

@nielsbasjes

Description

@nielsbasjes

Using com.google.cloud:google-cloud-nio:0.124.20 the CloudStorageFileSystemProvider implementation of FileSystemProvider.checkAccess fails when asking about the root directory.

Take this code fragment and fill in a cloud storage bucket name you have access to:

public class App {

    private static final Logger LOG = LoggerFactory.getLogger(App.class);

    public static void main(String[] args) {

        String bucketName = "xxxxxxxxxxxx";

        FileSystem fileSystem = FileSystems.getFileSystem(URI.create("gs://" + bucketName));

        Path path = fileSystem.getPath("/");

        FileSystemProvider provider = fileSystem.provider();
        try {
            provider.checkAccess(path, AccessMode.READ, AccessMode.WRITE);
        }
        catch (Exception e) {
            LOG.error("{}", e);
        }
        LOG.warn("{}", path);
    }
}

Stack trace

NOTE: I have hidden the real bucket name.

com.google.cloud.storage.StorageException: Invalid field selection bucket
	at com.google.cloud.storage.StorageException.translate(StorageException.java:163)
	at com.google.cloud.storage.spi.v1.HttpStorageRpc.translate(HttpStorageRpc.java:291)
	at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:517)
	at com.google.cloud.storage.StorageImpl.lambda$get$6(StorageImpl.java:298)
	at com.google.api.gax.retrying.DirectRetryingExecutor.submit(DirectRetryingExecutor.java:103)
	at com.google.cloud.RetryHelper.run(RetryHelper.java:76)
	at com.google.cloud.RetryHelper.runWithRetries(RetryHelper.java:50)
	at com.google.cloud.storage.Retrying.run(Retrying.java:60)
	at com.google.cloud.storage.StorageImpl.run(StorageImpl.java:1476)
	at com.google.cloud.storage.StorageImpl.get(StorageImpl.java:296)
	at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.checkAccess(CloudStorageFileSystemProvider.java:732)
	at nl.basjes.bugreports.App.main(App.java:31)
Caused by: com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request
GET https://storage.googleapis.com/storage/v1/b/xxxxxxxxxxxx/o/?fields=bucket,name,id&projection=full
{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "location" : "fields",
    "locationType" : "parameter",
    "message" : "Invalid field selection bucket",
    "reason" : "invalidParameter"
  } ],
  "message" : "Invalid field selection bucket"
}
	at com.google.api.client.googleapis.json.GoogleJsonResponseException.from(GoogleJsonResponseException.java:146)
	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:118)
	at com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest.newExceptionOnError(AbstractGoogleJsonClientRequest.java:37)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest$1.interceptResponse(AbstractGoogleClientRequest.java:439)
	at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1111)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:525)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.executeUnparsed(AbstractGoogleClientRequest.java:466)
	at com.google.api.client.googleapis.services.AbstractGoogleClientRequest.execute(AbstractGoogleClientRequest.java:576)
	at com.google.cloud.storage.spi.v1.HttpStorageRpc.get(HttpStorageRpc.java:514)
	... 9 more

External references such as API reference guides

Any additional information below

I ran into this problem when "simply" trying to attach Apache Mina SFTP to a Google Cloud Bucket.
Note that this all does work as expected on

  • existing files/directories
  • non-existing files/directories

Only on '/' it fails.

Metadata

Metadata

Assignees

Labels

api: storageIssues related to the googleapis/java-storage-nio API.status: investigatingThe issue is under investigation, which is determined to be non-trivial.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions