feat(http): support HTTP proxy via --http-client-trust-env (HAMR-393)#615
Merged
Merged
Conversation
Adds an opt-in --http-client-trust-env flag (env DD_HTTP_CLIENT_TRUST_ENV, default false) that enables aiohttp's trust_env on every ClientSession so the tool honors standard HTTP_PROXY/HTTPS_PROXY/NO_PROXY and .netrc settings, letting datadog-sync-cli run from restricted corporate-proxy environments. - constants.py: add DD_HTTP_CLIENT_TRUST_ENV - options.py: add --http-client-trust-env (mirrors --verify-ssl-certificates) - configuration.py: thread trust_env into all three CustomClient constructions (source, destination, reset) - custom_client.py: trust_env plumbed through _init_session (both SSL branches) and post_unauthenticated; verify_ssl/trust_env made keyword-only - synthetics_tests.py / synthetics_mobile_applications_versions.py: forward trust_env on the presigned-URL download sessions - README: document the flag and its security blast radius - tests: unit + CLI coverage for trust_env propagation and env-var coercion Environment: Datadog workspace Co-Authored-By: Claude Opus 4.8 (1M context) <[email protected]>
heyronhay
approved these changes
Jul 9, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds opt-in HTTP proxy support to
datadog-sync-cli. A new boolean flag--http-client-trust-env(env varDD_HTTP_CLIENT_TRUST_ENV, defaultfalse) enables aiohttp'strust_envon everyClientSessionthe tool creates, so it honors the standardHTTP_PROXY/HTTPS_PROXY/NO_PROXYenvironment variables (and.netrc).Why
Jira: HAMR-393 · Zendesk 2933103 (Hitachi, Premier).
aiohttpdefaults totrust_env=Falseand, unlikerequests, ignores proxy environment variables. There was previously no way to run the tool through a proxy, blocking a customer from backing up Datadog resources from a restricted corporate-proxy network. Enablingtrust_envis the fix the PSE investigation identified.Changes
constants.py— newDD_HTTP_CLIENT_TRUST_ENV.options.py— new--http-client-trust-envoption, modeled on--verify-ssl-certificates.configuration.py— reads the option and threadstrust_envinto all threeCustomClientconstructions (source, destination, and the reset path).custom_client.py—trust_envplumbed through_init_session(both SSL branches) andpost_unauthenticated.verify_ssl/trust_envare now keyword-only to prevent positional-argument mix-ups.synthetics_tests.py/synthetics_mobile_applications_versions.py— forwardtrust_envon the presigned-URL download sessions, so proxy support is complete for synthetics blob transfers too..netrccreds may be attached).tests/unit/test_custom_client_trust_env.py: unit coverage thattrust_envreaches every session constructor, plus CLI/env-var tests proving Click coercesDD_HTTP_CLIENT_TRUST_ENVstring values to a real bool (network-safe via mocked dispatch).Usage
Test plan
python -m pytest tests/unit/→ 814 passed, 8 skipped (skips pre-existing/unrelated).black+ruff(versions pinned intox.ini) clean.Follow-up (out of scope)
The four session-construction sites now duplicate the
ssl_context/TCPConnector/trust_envwiring. A shared session factory would collapse this to one place — deliberately deferred to keep this deadline-bound change small.🤖 Generated with Claude Code