Skip to content

[Core] Make NettyAsyncHttpClientBuilderTests proxy tests isolated from the agent environment - #50778

Closed
Isabelle (ibrandes) wants to merge 3 commits into
Azure:mainfrom
ibrandes:core/buildWithEnvConfigurationProxyFlakiness
Closed

Isabelle (ibrandes) wants to merge 3 commits into
Azure:mainfrom
ibrandes:core/buildWithEnvConfigurationProxyFlakiness

Conversation

@ibrandes

@ibrandes Isabelle (ibrandes) commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

This PR unblocks my netty 100 continue support PR by fixing the flaky/failing proxy tests causing CI failures. (Note: the CI failures began on October 7th before my netty 100 continue support PR)

Link to pipeline example failure

Summary

NettyAsyncHttpClientBuilderTests.buildWithEnvConfigurationProxy (and, latently, buildWithExplicitConfigurationProxy) read the real proxy environment of the CI agent, so they fail deterministically on hosted agents that sit behind a proxy. This PR makes proxy resolution in these tests self-contained by shadowing the ambient HTTP_PROXY/HTTPS_PROXY/NO_PROXY so the tests depend only on their own TestConfigurationSource values.

Root cause

com.azure.core.implementation.util.EnvironmentConfiguration.getOrLoad falls back to the real System.getenv(name) / System.getProperty(name) for any key a test ConfigurationSource leaves unset. The env-style test cases set only HTTP_PROXY, so HTTPS_PROXY and NO_PROXY fell through to the agent's real values. ProxyOptions.fromConfiguration reads HTTPS_PROXY before HTTP_PROXY and also reads NO_PROXY, which on hosted Windows agents (HTTPS_PROXY=http://10.x.x.x:18080, NO_PROXY=localhost,127.0.0.1,…) produced:

  • localhost targets bypassed by the real NO_PROXY → no proxy handler (expected: not <null>), and
  • authenticated external targets picking up the credential-less real HTTPS_PROXY → netty's plain HttpProxyHandler instead of Azure's (expected <true> but was <false>).

The buildWithExplicitConfigurationProxy supplier used the global-environment new ConfigurationBuilder(), so it had the same latent exposure.

Changes

Test-only, in sdk/core/azure-core-http-netty/.../NettyAsyncHttpClientBuilderTests.java:

  • Added a shared NEUTRAL_PROXY_ENV_SOURCE that sets HTTP_PROXY/HTTPS_PROXY/NO_PROXY to "", and used it as the environment source for every ConfigurationBuilder in both proxy-test suppliers (replacing EMPTY_SOURCE / the global new ConfigurationBuilder()).
  • For the two env-style cases that carry their proxy config in the environment slot (simpleEnvProxy, envProxyWithAuthentication), explicitly shadowed HTTPS_PROXY/NO_PROXY.

@ibrandes
Isabelle (ibrandes) requested a balanced review from Copilot October 13, 2026 19:26
@github-actions github-actions Bot added the Azure.Core azure-core label Oct 13, 2026
@ibrandes Isabelle (ibrandes) changed the title Make NettyAsyncHttpClientBuilderTests proxy tests isolated from the agent environment [Core] Make NettyAsyncHttpClientBuilderTests proxy tests isolated from the agent environment Oct 13, 2026
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
34 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Ambient JVM proxy properties can still leak into the tests and alter proxy selection.

1 open finding
What changed in this PR

Isolates Netty proxy tests from ambient CI proxy environment variables.

Changes:

  • Adds a neutral proxy environment source.
  • Applies it across environment and explicit proxy test configurations.
File Description
NettyAsyncHttpClientBuilderTests.java Shadows ambient proxy environment variables in proxy tests.

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

Two environment-proxy cases remain vulnerable to an ambient java.net.useSystemProxies JVM property.

0 open findings

1 resolved since last review

🧠 Review effort: Balanced

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

The focused test-only changes consistently prevent ambient proxy settings from affecting the tested scenarios.

0 open findings

🧠 Review effort: Balanced

@ibrandes

Copy link
Copy Markdown
Member Author

Issue was fixed after upgrading to Netty 4.2

@ibrandes
Isabelle (ibrandes) deleted the core/buildWithEnvConfigurationProxyFlakiness branch October 15, 2026 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Azure.Core azure-core

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants