fix: Correctly catch DefaultCredentialsError when looking up project_id by jonathanedey · Pull Request #720 · firebase/firebase-admin-python

@jonathanedey

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

@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 linked an issue

Sep 19, 2023

that may be closed by this pull request

lahirumaramba

project_id = self._credential.project_id
except AttributeError:
except (AttributeError, DefaultCredentialsError):
pass

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?

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

@jonathanedey

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.

lahirumaramba