fix: Differentiating explicitly loaded vs default credentials #764
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Modules like Firestore and Storage used to have the following bit of code:
firebase-admin-node/src/firestore/firestore.ts
Lines 98 to 110 in 00892e0
This allowed checking if the SDK was initialized with ADC, and if so delegating the credential loading back to the corresponding GCP library. In other cases (e.g. custom credentials), an error was thrown.
But in the v8.9.1 release this code was refactored into this:
firebase-admin-node/src/firestore/firestore.ts
Lines 88 to 100 in 5ce9175
But this is not quite equivalent to the logic we used to have, because:
The new
ComputeEngineCredential
only accounts for theMetadataServiceCredential
.In order to cover the remaining 2 cases, we need to differentiate the credentials that were explicitly instantiated by the developer and the credentials that were implicitly loaded by the SDK. This PR implements this capability and updates the rest of the code that depends on this behavior.
Resolves #763
RELEASE NOTE: Fixed a credential loading issue that prevented some Cloud Functions from being deployed via the Firebase CLI.