fix(gcp): ignore ADC errors when explicit credentials are provided #531
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.
Summary
Fixes an issue where
GoogleCloudStorageBuilderwould fail to build when Application Default Credentials (ADC) exist in an unsupported format, even when explicit credentials are provided viawith_service_account_path(),with_service_account_key(), orwith_credentials().Problem
Previously,
GoogleCloudStorageBuilder::build()unconditionally attempted to read ADC files and would fail immediately if the ADC format was unsupported (e.g.,external_account_authorized_userfrom Workload Identity Federation with external identity providers). This prevented users from using explicit credentials in environments where ADC was configured with newer credential types.Solution
This PR makes ADC reading conditional:
The credential precedence remains unchanged: explicit credentials > ADC > instance metadata
Changes
src/gcp/builder.rs:495-503to conditionally handle ADC reading errors based on whether explicit credentials were providedTesting
All tests pass (113 passed, 0 failed):
Impact
This change enables users in enterprise environments with Workload Identity Federation to use explicit credentials without being blocked by unsupported ADC formats, while maintaining backward compatibility and error visibility for ADC-only users.