Repository navigation
feat(api_core): restrict DirectPath to default universe - #19163
Conversation
There was a problem hiding this comment.
Code Review
This pull request restricts DirectPath and DirectPath over Interconnect to the Google Default Universe (GDU), disabling them if either the target host or the resolved credential's universe domain is not 'googleapis.com'. To support this, credential resolution was refactored out of composite credential creation to allow checking the universe domain earlier. Comprehensive unit and integration tests have been added to verify this behavior for both synchronous and asynchronous channels. I have no feedback to provide as there are no review comments.
There was a problem hiding this comment.
is this function still needed?
There was a problem hiding this comment.
Good catch, looks like we can remove this now
| quota_project_id=quota_project_id, | ||
| ) | ||
|
|
||
| if attempt_direct_path or attempt_direct_path_xds_over_interconnect is not None: |
There was a problem hiding this comment.
nit: this check can be moved before _resolve_credentials. helps in the case where an invalid GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS_OVER_INTERCONNECT fails fast without invoking google.auth.default().
Reject URL fragments ("#"), userinfo ("@" in netloc), and invalid DNS
labels in _has_default_universe_host() to align with #19163. Check "@"
on parsed.netloc rather than the raw URL so valid
service_account_impersonation_url paths containing service account
emails remain allowed.
b/588990592
DirectPath is currently only supported in the Google Default Universe (googleapis.com) in Python grpc. Currently, api_core allows a user to pass `attempt_direct_path` in any environment, and doesn't do any universe validation. This can be a problem when using services that enable direct path by default This PR disables DirectPath if not in the default universe
🤖 I have created a release *beep* *boop* --- <details><summary>gapic-generator: 1.44.3</summary> ## [1.44.3](gapic-generator-v1.44.2...gapic-generator-v1.44.3) (2026-12-02) ### Bug Fixes * **gapic-generator:** forward client_options to Extended Operations sub-clients ([#19293](#19293)) ([6dafcd3](6dafcd3)) * include version headers in long running operations ([#19059](#19059)) ([b91fab9](b91fab9)) </details> <details><summary>google-api-core: 2.45.0</summary> ## [2.45.0](google-api-core-v2.44.0...google-api-core-v2.45.0) (2026-12-02) ### Features * **api_core:** add error logging feature gate and shared transport attempt logging helpers ([#19009](#19009)) ([fa90cb6](fa90cb6)) * **api_core:** add HTTP transport attempt logging in _TraceContext ([#19011](#19011)) ([64b8e0e](64b8e0e)) * **api_core:** add shared universe_domain client and host helpers ([#19211](#19211)) ([be7a791](be7a791)) * **api_core:** add sync and async gRPC transport attempt logging interceptors ([#19010](#19010)) ([9394dc5](9394dc5)) * **api_core:** restrict DirectPath to default universe ([#19163](#19163)) ([ab6f215](ab6f215)) * **google-api-core:** centralize telemetry error attribute and trace context builders in _observability ([#18893](#18893)) ([e0fb81e](e0fb81e)) </details> <details><summary>google-cloud-documentai-toolbox: 0.17.6</summary> ## [0.17.6](google-cloud-documentai-toolbox-v0.17.5...google-cloud-documentai-toolbox-v0.17.6) (2026-12-02) ### Features * **documentai-toolbox:** drop Python 3.10 support ([#19128](#19128)) ([f6d50d7](f6d50d7)) </details> --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please). Co-authored-by: release-please[bot] <55107282+release-please[bot]@users.noreply.github.com>
DirectPath is currently only supported in the Google Default Universe (googleapis.com) in Python grpc.
Currently, api_core allows a user to pass
attempt_direct_pathin any environment, and doesn't do any universe validation. This can be a problem when using services that enable direct path by defaultThis PR disables DirectPath if not in the default universe