fix: apiCallTransport fallback 应保留环境变量代理#2128
fix: apiCallTransport fallback 应保留环境变量代理#2128zhoubeiqing wants to merge 3 commits intorouter-for-me:mainfrom
Conversation
当凭证和全局配置均未设置代理时,apiCallTransport 的 fallback 分支显式将 Proxy 设为 nil,禁用了环境变量代理(HTTP_PROXY/ HTTPS_PROXY)。而 codex_websockets_executor 中的 newProxyAwareWebsocketDialer 在相同场景下保留了 http.ProxyFromEnvironment 作为默认行为。 这一不一致导致管理面板通过 /v0/management/api-call 代理的 请求(如获取 Codex 额度)在仅配置了环境变量代理的部署环境中 无法到达上游服务,触发 30 秒超时。 修复方式:当没有显式代理配置时,直接返回 http.DefaultTransport, 保留其默认的 ProxyFromEnvironment 行为,与 WebSocket 执行器 保持一致。 Co-Authored-By: Claude Opus 4.6 <[email protected]>
Summary of ChangesHello, 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! 此拉取请求解决了应用程序中代理处理逻辑不一致的问题。它确保了当没有明确配置代理时, Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Changelog
Activity
Using Gemini Code AssistThe 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
Customization To customize 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 Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. 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. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
luispater
left a comment
There was a problem hiding this comment.
Thanks for the fix. The behavior change in apiCallTransport looks directionally correct and matches the websocket dialer by preserving ProxyFromEnvironment when no explicit proxy is configured.
I have one blocking concern before this should merge:
- Please add a regression test for the exact scenario this PR is fixing: when both
auth.ProxyURLandcfg.ProxyURLare empty,apiCallTransportshould inherit the environment proxy settings instead of disabling them. Right nowinternal/api/handlers/management/api_tools_test.goonly coversdirectand the invalid-auth-falls-back-to-global-proxy path, so the reported bug can regress again without any test failing.
Test plan I ran:
go test ./internal/api/handlers/managementgo test ./internal/runtime/executorgo test ./sdk/proxyutil
Once that coverage is in place, this looks good to me.
@luispater Added the regression test for the no-explicit-proxy case in api_tools_test.go. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a4bf698a7d
ℹ️ About Codex in GitHub
Your team has set up Codex to 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 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| rt := h.apiCallTransport(&coreauth.Auth{ProxyURL: ""}) | ||
| transport, ok := rt.(*http.Transport) | ||
| if ok && transport.Proxy != nil { |
There was a problem hiding this comment.
Fail test when apiCallTransport does not expose env proxy
This guard makes the new regression test pass even when apiCallTransport returns the wrong transport (for example, a non-*http.Transport or a transport with Proxy == nil), because execution falls through to checking http.ProxyFromEnvironment directly instead of asserting on rt. In that scenario, the test validates only the standard library behavior and would miss a real regression in apiCallTransport itself.
Useful? React with 👍 / 👎.
问题
apiCallTransport(api_tools.go)在凭证和全局配置均未设置代理时,fallback 分支显式将Proxy设为nil,禁用了环境变量代理(HTTP_PROXY/HTTPS_PROXY)。而
newProxyAwareWebsocketDialer(codex_websockets_executor.go)在相同场景下保留了http.ProxyFromEnvironment作为默认行为。两者行为不一致,导致管理面板通过
/v0/management/api-call代理的请求(如获取 Codex 额度)在仅配置了环境变量代理的部署环境中无法到达上游服务,触发超时。修复
当没有显式代理配置时,直接返回
http.DefaultTransport(默认包含ProxyFromEnvironment),与 WebSocket 执行器保持一致。🤖 Generated with Claude Code