Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Storage: Setting GOOGLE_APPLICATION_CREDENTIALS to a non-existent file silently falls back to the anonymous user #7184

Closed
sethvargo opened this issue Mar 31, 2020 · 4 comments
Assignees
Labels
api: storage Issues related to the Cloud Storage API. auth priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@sethvargo
Copy link
Contributor

Environment details

  1. OS type and version: Ubuntu, 18.04 (but reproduced elsewhere too)
  2. Java version: 1.8
  3. google-cloud-java version(s): 1.106.0

Steps to reproduce

  1. Set the environment variable GOOGLE_APPLICATION_CREDENTIALS to a non-existent filepath
  2. Run the code, note that it falls back to the anonymous user instead of erroring that the filepath given by GOOGLE_APPLICATION_CREDENTIALS is invalid or unreadable

Code example

import com.google.cloud.storage.Bucket;
import com.google.cloud.storage.Storage;
import com.google.cloud.storage.StorageOptions;
import java.io.ByteArrayInputStream;
import org.junit.jupiter.api.Test;

public class MyTest {

  @Test
  public void testGcp() {
    // Set GOOGLE_APPLICATION_CREDENTIALS=/foo/bar/baz first
    Storage storage = StorageOptions.getDefaultInstance().getService();

    Bucket bucket = storage.get("my-bucket");
    ByteArrayInputStream blobContent =
        new ByteArrayInputStream(bucket.get("schema.json").getContent());
  }
}
@yoshi-automation yoshi-automation added triage me I really want to be triaged. 🚨 This issue needs some love. labels Apr 1, 2020
@chingor13 chingor13 added priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Apr 6, 2020
@elharo
Copy link
Contributor

elharo commented Apr 7, 2020

Probably belongs to one of the auth repos?

@sethvargo
Copy link
Contributor Author

The code I traced is in this repo.

@elharo
Copy link
Contributor

elharo commented Apr 8, 2020

Do you have more details? Your sample code does not reference classes in this repo.

@yoshi-automation yoshi-automation removed 🚨 This issue needs some love. triage me I really want to be triaged. labels Apr 17, 2020
@frankyn frankyn added api: storage Issues related to the Cloud Storage API. auth and removed api: storage Issues related to the Cloud Storage API. labels Apr 27, 2020
@frankyn
Copy link
Member

frankyn commented Apr 27, 2020

Hi @sethvargo,

The java repository for Storage library is: https://github.com/googleapis/java-storage
Note that credentials are handled by the Java auth library (https://github.com/googleapis/google-auth-library-java).

Could you forward this issue there? Apologies for the delay.

@product-auto-label product-auto-label bot added the api: storage Issues related to the Cloud Storage API. label Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: storage Issues related to the Cloud Storage API. auth priority: p2 Moderately-important priority. Fix may not be included in next release. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

5 participants