Skip to content

fix(gemini): route Vertex token exchange through account proxy#2282

Closed
ZeroDeng01 wants to merge 1 commit intoWei-Shaw:mainfrom
ZeroDeng01:main
Closed

fix(gemini): route Vertex token exchange through account proxy#2282
ZeroDeng01 wants to merge 1 commit intoWei-Shaw:mainfrom
ZeroDeng01:main

Conversation

@ZeroDeng01
Copy link
Copy Markdown

@ZeroDeng01 ZeroDeng01 commented May 8, 2026

Summary

修复 Gemini Vertex Service Account 账号测试时,前置 OAuth token 请求没有使用账号代理的问题。
此前账号绑定代理后,后续 Vertex API 请求会走 httpUpstream 代理链路,但 Service Account 换取 access token 的请求仍使用裸 http.Client 直连 https://oauth2.googleapis.com/token,在无法直连 Google OAuth 的环境中会超时。

Changes

  • 让 Vertex Service Account token exchange 读取账号绑定的 proxy 配置。
  • 复用现有 proxyurlproxyutil 代理解析/Transport 配置逻辑。
  • 无账号代理时保留原有默认 HTTP client 行为。
  • 增加测试覆盖:
    • 账号代理 URL 提取逻辑。
    • token 请求会实际发送到配置的代理。

Testing

本地已做:

  • git diff --check
  • gofmt
  • go test ./backend/internal/service -run 'Test(VertexServiceAccountProxyURL|ExchangeVertexServiceAccountTokenUsesProxy)'
  • go test -tags=unit ./...
  • golangci-lint run ./...

Notes

这个修复覆盖的是 Vertex Service Account 的 OAuth token 获取阶段,也就是报错中的:

Post "https://oauth2.googleapis.com/token": context deadline exceeded

修复后,如果账号绑定了代理,这个 token 请求会和后续 Vertex API 请求一样使用账号代理网络。

close: #2252

I have read the CLA Document and I hereby sign the CLA

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 8, 2026

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@ZeroDeng01
Copy link
Copy Markdown
Author

I have read the CLA Document and I hereby sign the CLA

@ZeroDeng01
Copy link
Copy Markdown
Author

recheck

github-actions Bot added a commit that referenced this pull request May 8, 2026
@ZeroDeng01 ZeroDeng01 closed this May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gemini的Vertex渠道没有通过代理网络进行网络请求导致连通性问题

1 participant