Skip to content

fix: an empty proxy means a direct connection on all platforms - #2218

Open
orenjp wants to merge 3 commits into
getsentry:masterfrom
orenjp:fix/empty-proxy-direct
Open

orenjp wants to merge 3 commits into
getsentry:masterfrom
orenjp:fix/empty-proxy-direct

Conversation

@orenjp

@orenjp orenjp commented Oct 18, 2026

Copy link
Copy Markdown

sentry_options_set_proxy(options, "") is meant to turn the proxy off. Today it does so only where libcurl is used. Everywhere else, an empty proxy falls back to proxy discovery:

Transport Proxy "" before Proxy "" after
WinHTTP transport (Windows) system proxy (WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY) direct
curl transport (Linux, macOS) direct direct
crashpad handler, Linux direct (<empty>) direct
crashpad handler, Windows system proxy direct
crashpad handler, macOS system proxy direct
native backend daemon http_proxy/https_proxy, then the system proxy on Windows direct

The default (no sentry_options_set_proxy call) does not change.

This PR makes the following changes:

  • WinHTTP transport: opens the session with WINHTTP_ACCESS_TYPE_NO_PROXY for an empty proxy.
  • crashpad backend: passes <empty> to the handler on every platform, not only on Linux.
  • native backend: the daemon applied the proxy only when it was not empty, so it could not tell "" from no proxy. The shared context now carries has_proxy.
  • external/crashpad: points at fix: treat the <empty> proxy as a direct connection on Windows and macOS crashpad#175, which makes the Windows and macOS handlers treat <empty> as a direct connection.
  • sentry.h: the sentry_options_set_proxy doc says what an empty string does.

Tests

The existing test_proxy_set_empty and test_crashpad_proxy_set_empty set only the proxy environment variables. The WinHTTP transport and the Windows and macOS handlers never read those, so both tests pass with or without this change.

The new system_proxy helper in tests/proxy.py sets the current user's system proxy to the test proxy and restores it afterwards: WinINet on Windows, networksetup (with sudo -n) on macOS. It skips on other platforms. These tests use it:

  • test_proxy_system, for the WinHTTP transport on Windows.
  • test_crashpad_proxy_system, on Windows and macOS.
  • test_native_proxy_system, on Windows.

Each runs twice. With proxy_empty=False it checks that the request goes through the system proxy, which proves the setup works. With proxy_empty=True it checks that the proxy sees no request. test_native_proxy_set_empty is the environment-variable test the other backends already have.

The first commit adds only the tests, so CI shows them failing without the fix:

Related: getsentry/crashpad#176, a separate fix for the macOS proxy upload, which stops waiting after 10 seconds.

Oren Jacobian Pana added 2 commits October 18, 2026 22:28
The existing empty-proxy tests set only the `http_proxy`/`https_proxy`
environment variables, which the WinHTTP transport and the Windows and macOS
crashpad handlers never read, so they pass whether or not an empty proxy
turns proxy discovery off.

Add a `system_proxy` helper that points the current user's system proxy at
the test proxy (WinINet on Windows, `networksetup` on macOS) and restores it
afterwards. The tests run each backend once with the system proxy and once
with the system proxy plus an empty `proxy` option: the first checks that the
system proxy is in use, the second that the empty option bypasses it. The
native backend also gets the environment-variable test that the other
backends have.
`sentry_options_set_proxy(options, "")` turned off the proxy only where
libcurl is used. Elsewhere it fell back to proxy discovery:

- WinHTTP transport: opened the session with
  WINHTTP_ACCESS_TYPE_AUTOMATIC_PROXY, which reads the system settings.
- crashpad backend: passed `<empty>` to the handler only on Linux, so the
  Windows and macOS handlers used the system settings.
- native backend: the daemon applied the proxy only when it was not empty,
  so it fell back to the environment variables and system settings.

Open the WinHTTP session with WINHTTP_ACCESS_TYPE_NO_PROXY for an empty
proxy, pass `<empty>` to the crashpad handler on every platform, and tell
the native daemon whether a proxy was set. The crashpad submodule update
makes the Windows and macOS handlers treat `<empty>` as a direct
connection.
@codecov

codecov Bot commented Oct 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.69%. Comparing base (bbbd78c) to head (79a2a94).

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2218      +/-   ##
==========================================
+ Coverage   75.61%   75.69%   +0.08%     
==========================================
  Files         103      103              
  Lines       28261    28263       +2     
  Branches     5179     5180       +1     
==========================================
+ Hits        21369    21394      +25     
+ Misses       5536     5524      -12     
+ Partials     1356     1345      -11     
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

This branch has not been deployed

No deployments
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.

1 participant