Skip to content

fix(client): skip mTLS URL rewriting for multi-regional .rep.googleapis.com endpoints and honor GOOGLE_API_USE_MTLS_ENDPOINT in Google Auth sessions - #3135

Merged
copybara-service[bot] merged 1 commit into
mainfrom
copybara/998988334
Oct 21, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
copybara/998988334

Conversation

@copybara-service

Copy link
Copy Markdown

fix(client): skip mTLS URL rewriting for multi-regional .rep.googleapis.com endpoints and honor GOOGLE_API_USE_MTLS_ENDPOINT in Google Auth sessions

Multi-regional Vertex AI endpoints (aiplatform.us.rep.googleapis.com and aiplatform.eu.rep.googleapis.com) do not publish .rep.mtls.googleapis.com DNS records. When GOOGLE_API_USE_CLIENT_CERTIFICATE=true is set (such as on Vertex AI Agent Engine with AGENT_IDENTITY=true), rewriting these URLs in to_mtls_url() causes requests to fail with NXDOMAIN (Name or service not known).

Additionally, _request_once, _async_request_once, download_file, and async_download_file previously checked session._is_mtls directly when using AuthorizedSession / AsyncAuthorizedSession, bypassing _use_mtls_endpoint() and ignoring GOOGLE_API_USE_MTLS_ENDPOINT=never.

  • Update to_mtls_url() to leave multi-regional .us.rep. and .eu.rep. endpoints unchanged while continuing to rewrite single-region .rep. endpoints.
  • Gate to_mtls_url() in the synchronous and asynchronous Google Auth session paths via self._use_mtls_endpoint(client_cert_loaded=...).

…is.com endpoints and honor GOOGLE_API_USE_MTLS_ENDPOINT in Google Auth sessions

Multi-regional Vertex AI endpoints (`aiplatform.us.rep.googleapis.com` and `aiplatform.eu.rep.googleapis.com`) do not publish `.rep.mtls.googleapis.com` DNS records. When `GOOGLE_API_USE_CLIENT_CERTIFICATE=true` is set (such as on Vertex AI Agent Engine with `AGENT_IDENTITY=true`), rewriting these URLs in `to_mtls_url()` causes requests to fail with `NXDOMAIN` (`Name or service not known`).

Additionally, `_request_once`, `_async_request_once`, `download_file`, and `async_download_file` previously checked `session._is_mtls` directly when using `AuthorizedSession` / `AsyncAuthorizedSession`, bypassing `_use_mtls_endpoint()` and ignoring `GOOGLE_API_USE_MTLS_ENDPOINT=never`.

- Update `to_mtls_url()` to leave multi-regional `.us.rep.` and `.eu.rep.` endpoints unchanged while continuing to rewrite single-region `.rep.` endpoints.
- Gate `to_mtls_url()` in the synchronous and asynchronous Google Auth session paths via `self._use_mtls_endpoint(client_cert_loaded=...)`.

PiperOrigin-RevId: 1004213757
@copybara-service
copybara-service Bot merged commit 4e44c84 into main Oct 21, 2026
13 checks passed
@copybara-service
copybara-service Bot deleted the copybara/998988334 branch October 21, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant