nicktp opened a new issue, #3577:
URL: https://github.com/apache/incubator-opendal/issues/3577

   The way that the methods of `AwsConfig` (from the `reqsign crate`) are 
called, `S3Builder` does not respect the active AWS profile and instead will 
use whatever is configured as the `default` profile.  This can leave the 
`AwsConfig` object in an inconsistent state which could make debugging issues 
harder for a user.
   
   The relevant lines are in `opendal/services/s3/backend.rs`, 849-852.  
   ```rust
   let mut cfg = AwsConfig::default();  // Creates a config with `profile: 
default` (https://docs.rs/reqsign/latest/src/reqsign/aws/config.rs.html#89)
   if !self.config.disable_config_load {
       cfg = cfg.from_profile();        // Uses profile value set by 
`default()` (https://docs.rs/reqsign/latest/src/reqsign/aws/config.rs.html#178)
       cfg = cfg.from_env();            // Overrides profile using 
`AWS_PROFILE` 
(https://docs.rs/reqsign/latest/src/reqsign/aws/config.rs.html#119) 
                                        //  but unless the other `AWS_***` env 
vars are set, this leaves the config
                                        // in an inconsistent state.
   }
   ```
   
   I can see that there's a tension between the profile and environment 
variable methods and this code is trying to cover all bases but as a user who 
uses multiple AWS profiles and switches between them using the AWS_PROFILE 
environment variable, I expect my active profile to be respected, especially if 
`disable_config_load` hasn't been set.
   
   How about the following which does check of the env var before populating 
from the profile?
   
   ```rust
   use std::env;
   
   let mut cfg = AwsConfig::default();  
   if !self.config.disable_config_load {
       if let Ok(profile) = env::var("AWS_PROFILE") {
           cfg.profile = profile;
       }
   
       cfg = cfg.from_profile(); 
       cfg = cfg.from_env();  // Could still leave cfg in an inconsistent state 
but not because of an unintended profile mismatch
   }


-- 
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]

Reply via email to