Skip to content

fix(core): respect NO_PROXY in global fetch dispatcher#27216

Merged
cocosheng-g merged 6 commits into
google-gemini:mainfrom
cocosheng-g:fix/issue-23372-proxy-bypass
May 19, 2026
Merged

fix(core): respect NO_PROXY in global fetch dispatcher#27216
cocosheng-g merged 6 commits into
google-gemini:mainfrom
cocosheng-g:fix/issue-23372-proxy-bypass

Conversation

@cocosheng-g

Copy link
Copy Markdown
Contributor

Summary

Fix global fetch dispatcher to respect NO_PROXY by using EnvHttpProxyAgent.

Details

Modified packages/core/src/utils/fetch.ts to switch from ProxyAgent to EnvHttpProxyAgent. This ensures that local traffic (localhost, 127.0.0.1) bypasses the proxy when NO_PROXY is configured. Also updated setGlobalProxy and createSafeProxyAgent to use httpProxy and httpsProxy options for consistency.

Related Issues

Fixes #23372

How to Validate

  1. Run npm test -w @google/gemini-cli-core -- src/utils/fetch.test.ts
  2. Run npm test -w @google/gemini-cli-core -- src/utils/proxy_bypass.test.ts
  3. Manual verification: Set HTTPS_PROXY to a dummy value and NO_PROXY to localhost, then attempt a local request. It should bypass the proxy and succeed.

Pre-Merge Checklist

  • Updated relevant documentation and README (if needed)
  • Added/updated tests (if needed)
  • Noted breaking changes (if any)
  • Validated on required platforms/methods:
    • MacOS
      • npm run
      • npx
      • Docker
      • Podman
      • Seatbelt

@cocosheng-g cocosheng-g requested a review from a team as a code owner May 18, 2026 16:58
@cocosheng-g

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request improves the global fetch dispatcher by transitioning to EnvHttpProxyAgent. This change allows the application to respect the NO_PROXY environment variable, ensuring that requests to local addresses are not routed through configured proxies. The update includes necessary adjustments to utility functions and comprehensive integration tests to validate the bypass behavior.

Highlights

  • Proxy Configuration Update: Replaced the standard ProxyAgent with EnvHttpProxyAgent in the global fetch dispatcher to enable support for the NO_PROXY environment variable.
  • Environment Variable Support: Updated setGlobalProxy and createSafeProxyAgent to read from NO_PROXY or no_proxy environment variables, ensuring local traffic correctly bypasses proxy settings.
  • Integration Testing: Added a new test suite, proxy_bypass.test.ts, to verify that local requests successfully bypass the proxy when configured.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-cli gemini-cli Bot added priority/p2 Important but can be addressed in a future release. area/core Issues related to User Interface, OS Support, Core Functionality labels May 18, 2026

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request replaces the ProxyAgent with EnvHttpProxyAgent from the undici library to better support proxy bypass configurations via NO_PROXY and no_proxy environment variables. It also includes a new integration test suite to verify that local requests correctly bypass the proxy. The reviewer identified that createSafeProxyAgent is missing explicit timeout configurations, which could lead to premature timeouts during long-running requests, and recommended trimming input strings for better robustness.

Comment thread packages/core/src/utils/fetch.ts

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request replaces the ProxyAgent with EnvHttpProxyAgent in the core fetch utilities to support proxy bypassing via the NO_PROXY and no_proxy environment variables. It includes updates to existing tests and a new integration test suite for proxy bypass logic. The reviewer suggested awaiting the asynchronous server.close() call in the integration tests to prevent potential flakiness and resource leaks.

Comment thread packages/core/src/utils/proxy_bypass.test.ts Outdated
@cocosheng-g

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request replaces the ProxyAgent with EnvHttpProxyAgent from the undici library to improve proxy management. The changes include support for the NO_PROXY and no_proxy environment variables in both createSafeProxyAgent and setGlobalProxy, along with automatic trimming of proxy URLs. A new test suite, proxy_bypass.test.ts, has been added to verify that proxy bypass logic works correctly for local addresses. I have no feedback to provide as there were no review comments.

@cocosheng-g cocosheng-g requested a review from a team as a code owner May 18, 2026 18:31
@cocosheng-g cocosheng-g force-pushed the fix/issue-23372-proxy-bypass branch from 70729ed to e9abd47 Compare May 19, 2026 14:13
@cocosheng-g cocosheng-g requested a review from a team as a code owner May 19, 2026 14:49
@github-actions

Copy link
Copy Markdown

🛑 Action Required: Evaluation Approval

Steering changes have been detected in this PR. To prevent regressions, a maintainer must approve the evaluation run before this PR can be merged.

Maintainers:

  1. Go to the Workflow Run Summary.
  2. Click the yellow 'Review deployments' button.
  3. Select the 'eval-gate' environment and click 'Approve'.

Once approved, the evaluation results will be posted here automatically.

@cocosheng-g cocosheng-g force-pushed the fix/issue-23372-proxy-bypass branch from 38db941 to df26857 Compare May 19, 2026 15:22
@cocosheng-g cocosheng-g enabled auto-merge May 19, 2026 16:25
@cocosheng-g cocosheng-g added this pull request to the merge queue May 19, 2026
@github-merge-queue github-merge-queue Bot removed this pull request from the merge queue due to failed status checks May 19, 2026
@cocosheng-g cocosheng-g added this pull request to the merge queue May 19, 2026
Merged via the queue into google-gemini:main with commit 37f3a4c May 19, 2026
27 checks passed
@cocosheng-g cocosheng-g deleted the fix/issue-23372-proxy-bypass branch May 19, 2026 18:33
@sripasg sripasg added the size/m A medium sized PR label Jun 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/core Issues related to User Interface, OS Support, Core Functionality priority/p2 Important but can be addressed in a future release. size/m A medium sized PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Proxy local bypass does not recognize environment variables

4 participants