-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow $AWS_PROFILE to be blank #3110
Comments
Thanks for reaching out and your patience in hearing back here. It looks like we missed this issue. This request would need to go to our cross-SDK repository (https://github.com/aws/aws-sdk/issues) since it involves an environment variable which is used across SDKs. Could you create a feature request there outlining your use case? I don't think this would be considered because of the need to retain backwards compatibility though. |
This issue is now closed. Comments on closed issues are hard for our team to see. |
1 similar comment
This issue is now closed. Comments on closed issues are hard for our team to see. |
Describe the bug
If the environment variable
AWS_PROFILE
is set to an empty string, thenboto3.client
raises an exception. It does so even if client credentials are explicitly specified by keyword arguments or other means.Expected behavior
Setting
AWS_PROFILE=
should be treated the same way as havingAWS_PROFILE
unset (i.e., it should fall back to other methods for determining credentials.)There's no rule or standard saying that you need to treat an empty environment variable the same as one that is undefined - it's just common practice and good if you want to avoid surprising people. In the case of boto3, it's impossible to have a profile with an empty name, so it doesn't make sense to try to search for one.
Current behavior
If
AWS_PROFILE
is set to an empty string, thenboto3.client('s3')
raisesbotocore.exceptions.ProfileNotFound
, apparently regardless of what other arguments or environment variables are defined.Reproduction Steps
This succeeds (and returns a client with no credentials):
This succeeds (and returns a client with credentials):
This ought to succeed (and return a client with no credentials):
This ought to succeed (and return a client with credentials):
Possible Solution
In
botocore.session.Session.get_scoped_config
:Additional Information/Context
For one example of where this issue is an annoyance: Python's
unittest.mock.patch.dict
provides an easy way to temporarily override environment variables for a unit test, but it doesn't let you undefine variables.SDK version used
boto3 1.34.31
botocore 1.34.31
Environment details (OS name and version, etc.)
Debian 12, Python 3.11
The text was updated successfully, but these errors were encountered: