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

feat: honor http_proxy environment variables #1111

Open
wants to merge 59 commits into
base: master
Choose a base branch
from

Conversation

JoshuaMoelans
Copy link
Member

@JoshuaMoelans JoshuaMoelans commented Jan 9, 2025

Fixes #787

Overview

This started as an additional option to configure, but testing revealed that (some) transports already honor the variable. This PR is now mainly an extensive testing effort to reason about the boundaries & quirks of http_proxy.

One major addition was made to the crashpad handler which now also reads the environment variable if it was set.

TODO

Done

Copy link

codecov bot commented Jan 9, 2025

Codecov Report

Attention: Patch coverage is 69.23077% with 8 lines in your changes missing coverage. Please review.

Project coverage is 82.56%. Comparing base (d90eec1) to head (93678e0).
Report is 5 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1111      +/-   ##
==========================================
- Coverage   82.68%   82.56%   -0.13%     
==========================================
  Files          53       53              
  Lines        7930     7942      +12     
  Branches     1240     1246       +6     
==========================================
  Hits         6557     6557              
- Misses       1263     1270       +7     
- Partials      110      115       +5     

Comment on lines 141 to 143
if (options->read_proxy_from_environment) {
sentry__set_proxy_from_environment(options);
}
Copy link
Member Author

Choose a reason for hiding this comment

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

With this new option, I'm not sure we still need to support no_proxy; if users want to use the environment variable value in their own code, they can just not set this flag to true (which is the default anyway).

Copy link
Collaborator

@supervacuus supervacuus Jan 13, 2025

Choose a reason for hiding this comment

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

Yes and no. You always have to consider that this is a feature that the users of our users require from them.

So, for instance, if your application ignores the http_proxy env-vars, your users don't care about the topic and accept that they have to manually configure the proxy config for that application (or even have no proxy config at all).

At some point, you might provide a UI to your users that does something like the following:

(   ) direct HTTP connection.
(   ) manually specify HTTP proxy: _________ .
( * ) read proxy from the environment.

You can route this directly to our proposed options interface. However, once your users have configured the app to read from the environment, they will want to stay with it because it allows them to have a centrally managed proxy configuration rather than defining it separately in every application.

This is where no_proxy enters the picture. So, yes, resetting the proxy config of that app solves the problem, but then the users of our users are essentially back to square 1. Again, this is not a requirement for an initial implementation of that feature but a likely follow-up.

@JoshuaMoelans JoshuaMoelans marked this pull request as ready for review January 14, 2025 12:04
src/sentry_options.c Outdated Show resolved Hide resolved
src/sentry_options.c Outdated Show resolved Hide resolved
include/sentry.h Outdated Show resolved Hide resolved
src/transports/sentry_transport_winhttp.c Outdated Show resolved Hide resolved
src/transports/sentry_transport_winhttp.c Outdated Show resolved Hide resolved
src/transports/sentry_transport_winhttp.c Outdated Show resolved Hide resolved
Copy link
Collaborator

@supervacuus supervacuus left a comment

Choose a reason for hiding this comment

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

👍

@JoshuaMoelans
Copy link
Member Author

We still need to find a way to work around WinINet bypassing the localhost->localhost proxy in our test environment. Locally this was tested by adding a line to the Windows hosts file

127.0.0.1        sentry_native.test 

@JoshuaMoelans
Copy link
Member Author

Also, now that we test whether the proxy actually gets used when we prompt it to, this crashpad socks5-proxy test fails on macOS (see runner output). It seems like the proxy isn't used, but when trying this with a non-localhost DSN it seems to work (similar to the remaining Windows failures)).

FAILED tests/test_integration_crashpad.py::test_crashpad_crash_proxy[True-run_args1] - AssertionError

Copy link
Member Author

@JoshuaMoelans JoshuaMoelans left a comment

Choose a reason for hiding this comment

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

Almost there, just a few remarks left.

@@ -11,3 +11,5 @@ leak:SCDynamicStoreCopyProxiesWithOptions
# This is a known issue in ASAN packaged with llvm15/16 (and below): https://github.com/google/sanitizers/issues/1501
# I cannot reproduce it with the current brew llvm package (18.1.7). TODO: remove when GHA macOS runner image updates the llvm package.
leak:realizeClassWithoutSwift

leak:Curl_getaddrinfo_ex
Copy link
Member Author

Choose a reason for hiding this comment

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

src/backends/sentry_backend_crashpad.cpp Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Honor http_proxy environment variables
2 participants