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

fix: Correctly catch DefaultCredentialsError when looking up project_id #720

Merged
merged 3 commits into from
Sep 21, 2023

Conversation

jonathanedey
Copy link
Contributor

DefaultCredentialsError was not being caught when trying to load project_id from credentials.

Added a catch for this error along with unit tests.

Related: #609

@jonathanedey jonathanedey changed the title fix: Correctly catch DefaultCredentialsError when looking up prodject_id fix: Correctly catch DefaultCredentialsError when looking up project_id Sep 19, 2023
@jonathanedey jonathanedey marked this pull request as ready for review September 19, 2023 16:04
@jonathanedey jonathanedey linked an issue Sep 19, 2023 that may be closed by this pull request
@@ -257,7 +258,7 @@ def _lookup_project_id(self):
if not project_id:
try:
project_id = self._credential.project_id
except AttributeError:
except (AttributeError, DefaultCredentialsError):
pass
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to throw here or pass?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We want to pass and look for other ways of getting a project_id.

@jonathanedey
Copy link
Contributor Author

Noticed that I am not explicitly triggering the exceptions in the unit tests. Doing that caught that I also needed to clear gcloud env to ensure the exception is thrown.

@jonathanedey jonathanedey merged commit aef52be into master Sep 21, 2023
11 checks passed
@lahirumaramba lahirumaramba deleted the je-fix-609 branch September 25, 2023 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Using Auth Client with Emulator without Credentials Doesn't Work
2 participants