fix: sanitize NO_PROXY newlines#3305
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 9ac1cd1640
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if value is not None: | ||
| os.environ[key] = _sanitize_no_proxy(value) |
There was a problem hiding this comment.
Avoid mutating process env while constructing clients
Writing the sanitized value back into os.environ makes client construction mutate global process state, so creating one SDK client permanently rewrites NO_PROXY/no_proxy for all other code in the same process. This can cause hard-to-debug cross-library side effects (or racey behavior in multi-threaded apps) unrelated to this client instance; the sanitization should be scoped to the httpx initialization path rather than persisted globally.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Thanks, fixed in a5d226f. The NO_PROXY/no_proxy cleanup is now scoped to the default httpx client proxy map construction instead of writing back to os.environ, and the tests assert the environment value remains unchanged.
Changes being requested
Sanitize newline and carriage-return separators in NO_PROXY/no_proxy before constructing the SDK's default httpx clients, so Docker/.env-style multiline NO_PROXY values do not raise httpx.InvalidURL.
Fixes #3303
Additional context & links
Tests run: