Skip to content
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

AWS SDK Compatibility: Check for http_proxy & https_proxy environment variables #2991

Merged
merged 5 commits into from Jan 3, 2024

Conversation

Mythra
Copy link
Contributor

@Mythra Mythra commented Jul 6, 2023

Description

this brings us in line with many other AWS SDKs which check for these environment variables to modify client behavior. it does not change behavior if you've already been setting your web proxy explicitly, or in properties (the same as the java (and other) sdks).

we do introduce this with two new methods in ClientConfig to not break any existing callers using the methods that are public. while all of our callers have been updated to properly check web proxy, and then if that's unset check the protocol being used and optionally call GetHttpProxy/GetHttpsProxy as needed. If we're okay with breaking ever IT MAY be worthwhile to break GetWebProxy by taking in the protocol, and then just having the one method to prevent any accidental mis-use, and to ensure everyone is using those environment variables.

it's also important to note:
dotnet/runtime#31113 meaning a user will just get an error if they try to proxy to something that is using HTTPS. i figured just letting it error on construction is probably the 'safest' option. letting the user know that their setting isn't being respected, as opposed to just silently 'ignoring' it. this is also a decision we might want to change.

Motivation and Context

fixes #1977

Testing

  • I've manually ensured unit tests pass locally.
  • I've confirmed that running integration tests connect through a proxy configured through an environment variable

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the README document
  • I have added tests to cover my changes
  • All new and existing tests passed

License

  • I confirm that this pull request can be released under the Apache 2 license

this brings us in line with many other AWS SDKs which check for
these environment variables to modify client behavior. it does not
change behavior if you've already been setting your web proxy
explicitly, or in properties (the same as the java (and other) sdks).

we do introduce this with two new methods in ClientConfig to not break
any existing callers using the methods that are public. while all of our
callers have been updated to properly check web proxy, and then if
that's unset check the protocol being used and optionally call
`GetHttpProxy`/`GetHttpsProxy` as needed. If we're okay with breaking
ever IT MAY be worthwhile to break `GetWebProxy` by taking in the
protocol, and then just having the one method to prevent any accidental
mis-use, and to ensure everyone is using those environment variables.

it's also important to note:
<dotnet/runtime#31113> meaning a user will
just get an error if they try to proxy to something that is using
`HTTPS`. i figured just letting it error on construction is probably
the 'safest' option. letting the user know that their setting isn't
being respected, as opposed to just silently 'ignoring' it. this is
also a decision we might want to change.
@dscpinheiro
Copy link
Contributor

Thanks a lot for the PR, we're discussing internally what should be done for the other SDKs that don't support these environment variables (aws/aws-sdk#538 (comment)).

@peterrsongg peterrsongg self-requested a review August 29, 2023 21:41
@ashishdhingra ashishdhingra added feature-request A feature should be added or improved. p2 This is a standard priority issue queued cross-sdk labels Sep 1, 2023
@normj normj changed the base branch from master to main-staging October 9, 2023 18:13
@dscpinheiro dscpinheiro self-assigned this Nov 21, 2023
@dscpinheiro dscpinheiro requested review from normj and dscpinheiro and removed request for peterrsongg November 21, 2023 18:45
@ashovlin ashovlin self-requested a review November 29, 2023 18:28
@ashovlin ashovlin removed their request for review December 4, 2023 17:32
Ensure we read explicitly configured proxies through code first,
and then fallback to reading the proxy from environment variables.
next add some tests with the recommended environment variable mocking
test setup provided.
@ashishdhingra
Copy link
Contributor

@Mythra Could you please have a look at review comments and help address these in order to proceed further.

@Mythra
Copy link
Contributor Author

Mythra commented Dec 15, 2023

Hey @ashishdhingra yep, I saw the comments and will get to it, but it's also the holidays and I'm otherwise preoccupied at the moment. I'll get to it as soon as I can as it is really important I've been watching it like a hawk. Thanks!

@Mythra
Copy link
Contributor Author

Mythra commented Dec 28, 2023

I've come back from holidays, and made the changes!

Copy link
Member

@normj normj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks for making the change and the PR!

@dscpinheiro dscpinheiro merged commit 8cf768c into aws:main-staging Jan 3, 2024
@dscpinheiro
Copy link
Contributor

Thanks again for the contribution, we really appreciate it!

This will be included in the next SDK release (which should happen tomorrow).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cross-sdk feature-request A feature should be added or improved. p2 This is a standard priority issue queued
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.NET SDK should support environment variables http_proxy and https_proxy (as AWS CLI does)
5 participants