This repository was archived by the owner on Apr 2, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 35
This repository was archived by the owner on Apr 2, 2026. It is now read-only.
NPE in requesterPays check if credentials don't match provided user project #849
Copy link
Copy link
Closed
Labels
api: storageIssues related to the googleapis/java-storage-nio API.Issues related to the googleapis/java-storage-nio API.
Description
The last release introduced a new NullPointerException when trying to use an invalid service account to access a requester pays bucket. The null pointer hides the actual cause of the error which makes it hard to debug. (Although the cause is not particularly clear from the original error message anyway)
Expect to see something like this:
Error getting access token for service account: 400 Bad Request
POST https://oauth2.googleapis.com/token
{"error":"invalid_grant","error_description":"Invalid JWT Signature."}, iss: 806222273987-uilktks3j6i7962rp0v7nusveer58497@developer.gserviceaccount.com
com.google.cloud.storage.StorageException: Error getting access token for service account: 400 Bad Request
....
But instead you get
java.lang.NullPointerException
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.requesterPays(CloudStorageFileSystemProvider.java:970)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.<init>(CloudStorageFileSystem.java:209)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket(CloudStorageFileSystem.java:196)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket(CloudStorageFileSystem.java:164)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket(CloudStorageFileSystem.java:154)
at org.broadinstitute.hellbender.utils.gcs.BucketUtils.getPathOnGcs(BucketUtils.java:410)
at org.broadinstitute.hellbender.utils.io.IOUtils.getPath(IOUtils.java:773)
at org.broadinstitute.hellbender.utils.gcs.BucketUtilsUnitTest.throwNPE(BucketUtilsUnitTest.java:421)
Environment details
- Cloud NIO
- OS type and version: all
- Java version: all
- version(s): 0.123.23
Steps to reproduce
- Attempt to check requester pays status of a bucket under these conditions:
- correctly formatted but revoked service account credentials
- autoDetectRequesterPays = true
- NPE
Code example
@Test
public void throwNPE() throws IOException {
CloudStorageFileSystemProvider.setDefaultCloudStorageConfiguration(
CloudStorageConfiguration.builder()
.autoDetectRequesterPays(true)
.userProject("ANY_PROJECT_NAME")
.build());
CloudStorageFileSystemProvider.setStorageOptions(
StorageOptions.newBuilder()
.setCredentials(ServiceAccountCredentials.fromStream(new FileInputStream(INVALID_KEY)))
.build()
);
final Path path = IOUtils.getPath(FILE_IN_REQUESTER_PAYS_BUCKET);
}Stack trace
java.lang.NullPointerException
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystemProvider.requesterPays(CloudStorageFileSystemProvider.java:970)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.<init>(CloudStorageFileSystem.java:209)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket(CloudStorageFileSystem.java:196)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket(CloudStorageFileSystem.java:164)
at com.google.cloud.storage.contrib.nio.CloudStorageFileSystem.forBucket(CloudStorageFileSystem.java:154)
at org.broadinstitute.hellbender.utils.gcs.BucketUtils.getPathOnGcs(BucketUtils.java:410)
at org.broadinstitute.hellbender.utils.io.IOUtils.getPath(IOUtils.java:773)
at org.broadinstitute.hellbender.utils.gcs.BucketUtilsUnitTest.throwNPE(BucketUtilsUnitTest.java:421)
...
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
api: storageIssues related to the googleapis/java-storage-nio API.Issues related to the googleapis/java-storage-nio API.