Xuanwo opened a new issue, #8874:
URL: https://github.com/apache/opendal/issues/8874
## Problems
Both `core/services/gcs/src/backend.rs` and
`core/services/gcs-grpc/src/backend.rs` share two credential setup issues:
1. **Silent error swallowing on invalid base64 `credential`**:
- `core/services/gcs/src/backend.rs:326-330`:
```rust
if let Some(content) = self.config.credential.as_deref()
&& let Ok(provider) = StaticCredentialProvider::from_base64(content)
{
credential_chain =
credential_chain.push_front(provider.with_scope(&scope));
}
```
- `core/services/gcs-grpc/src/backend.rs:212-216`: identical pattern.
- When a caller explicitly sets `credential` to invalid base64 (or
malformed input rejected by `from_base64`), `build()` silently ignores the
error and falls back to the default ADC / VM metadata chain instead of
returning `ErrorKind::ConfigInvalid`.
2. **Obsolete `StaticEnv` snapshot hack for `GOOGLE_SCOPE` and redundant VM
metadata wiring**:
- Both backends (`gcs/src/backend.rs:286-320`,
`gcs-grpc/src/backend.rs:183-207`) snapshot the entire process `OsEnv` into
`StaticEnv` solely to insert `GOOGLE_SCOPE`, and when
`self.config.service_account` is set, call `.no_vm_metadata()` only to push a
separate `VmMetadataCredentialProvider` afterward.
- In `reqsign-google`, `EnvCredentialProvider`,
`WellKnownCredentialProvider`, and `VmMetadataCredentialProvider` all provide
`.with_scope(&scope)` directly, and `DefaultCredentialProvider::builder()`
accepts `.env(...)`, `.well_known(...)`, and `.vm_metadata(...)`.
- Using `OsEnv` + typed `.with_scope(&scope)` (and
`.vm_metadata(VmMetadataCredentialProvider::new().with_scope(&scope).with_service_account(sa))`)
removes the `StaticEnv` snapshot and keeps the provider chain clean.
## Expected behavior
- Invalid `config.credential` returns `Error::new(ErrorKind::ConfigInvalid,
...)` from `Builder::build()`.
- Both `gcs` and `gcs-grpc` use `OsEnv` and typed `.with_scope(&scope)`
builders on `DefaultCredentialProvider::builder()`.
- Unit tests verify invalid base64 `credential` fails with
`ErrorKind::ConfigInvalid` in both `gcs` and `gcs-grpc`.
---
*Drafted with AI assistance (Gemini 4 Neon) and verified against
`core/services/gcs/src/backend.rs`, `core/services/gcs-grpc/src/backend.rs`,
and `reqsign-google` `v0.20.9`.*
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]