Repository navigation
fix: retrieve the live discovery document from the client's universe domain #2862
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
d2df49f
eba7750
d48267e
4fba277
80ca1bd
891b333
51c9e7b
e3a9778
0994b20
205bba3
89e313e
9b23f4e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,130 @@ | ||
| # Copyright 2026 Google LLC | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
|
|
||
| """Universe domain compatibility helpers. | ||
| Prefers ``google.api_core.universe.resolve_client_universe`` when available | ||
| (>= 2.45.0) and falls back to a local copy for older ``google-api-core`` | ||
| releases. | ||
| """ | ||
|
|
||
| import collections.abc | ||
| import os | ||
|
|
||
| from google.api_core import client_options as client_options_lib | ||
| from google.auth import credentials as google_auth_credentials | ||
|
|
||
| GOOGLE_CLOUD_UNIVERSE_DOMAIN = "GOOGLE_CLOUD_UNIVERSE_DOMAIN" | ||
| DEFAULT_UNIVERSE = "googleapis.com" | ||
|
|
||
|
|
||
| class APICoreVersionError(ValueError): | ||
| def __init__(self): | ||
| message = ( | ||
| "google-api-core >= 2.18.0 is required to use the universe domain feature." | ||
| ) | ||
| super().__init__(message) | ||
|
|
||
|
|
||
| try: | ||
| from google.api_core import universe as api_core_universe | ||
|
|
||
| HAS_UNIVERSE = True | ||
| except ImportError: | ||
| api_core_universe = None | ||
| HAS_UNIVERSE = False | ||
|
|
||
| try: | ||
| from google.auth.aio import credentials as _aio_credentials | ||
|
|
||
| _ANONYMOUS_CREDENTIAL_TYPES = ( | ||
| google_auth_credentials.AnonymousCredentials, | ||
| _aio_credentials.AnonymousCredentials, | ||
| ) | ||
| except ImportError: # pragma: NO COVER | ||
| _ANONYMOUS_CREDENTIAL_TYPES = (google_auth_credentials.AnonymousCredentials,) | ||
|
|
||
| try: | ||
| from google.api_core.universe import resolve_client_universe | ||
| except ImportError: | ||
| # TODO(https://github.com/googleapis/google-cloud-python/issues/19297): Replace with | ||
| # google.api_core.universe.resolve_client_universe once minimum allowed | ||
| # google-api-core version exceeds 2.44.0. | ||
| def resolve_client_universe(client_options=None): | ||
| """Resolve a client's universe domain from ``client_options`` or the environment.""" | ||
| if client_options is None: | ||
| options_universe = None | ||
| elif isinstance(client_options, collections.abc.Mapping): | ||
| options_universe = client_options.get("universe_domain") | ||
| elif isinstance(client_options, client_options_lib.ClientOptions): | ||
| # Versions of google-api-core that predate universe domains (< 2.18.0) | ||
| # have no `universe_domain` attribute on ClientOptions. | ||
| options_universe = getattr(client_options, "universe_domain", None) | ||
| else: | ||
| raise TypeError( | ||
| "client_options must be a ClientOptions instance, Mapping, or None; " | ||
| f"got {type(client_options).__name__}" | ||
| ) | ||
| # Strip before checking/determine_domain so surrounding whitespace is | ||
| # removed from non-empty values even on older google-api-core releases. | ||
| stripped_options = ( | ||
| options_universe.strip() | ||
| if isinstance(options_universe, str) | ||
| else options_universe | ||
| ) | ||
| env_universe = os.getenv(GOOGLE_CLOUD_UNIVERSE_DOMAIN) | ||
| stripped_env = ( | ||
| env_universe.strip() if isinstance(env_universe, str) else env_universe | ||
| ) | ||
| if not HAS_UNIVERSE: | ||
| # Older google-api-core (< 2.18.0) cannot route to non-default | ||
| # universes; fail before any request if a universe is configured. | ||
| if stripped_options is not None or ( | ||
| stripped_env is not None and stripped_env != DEFAULT_UNIVERSE | ||
| ): | ||
| raise APICoreVersionError | ||
| return None | ||
| return api_core_universe.determine_domain( | ||
| stripped_options, | ||
| stripped_env, | ||
| ) | ||
|
|
||
|
|
||
| def check_api_core_compatible_with_credentials_universe(credentials): | ||
| """Raise APICoreVersionError if credentials require universe support.""" | ||
| if not HAS_UNIVERSE: | ||
| credentials_universe = getattr(credentials, "universe_domain", None) | ||
| if credentials_universe and credentials_universe != DEFAULT_UNIVERSE: | ||
| raise APICoreVersionError | ||
|
|
||
|
|
||
| def validate_request_credentials_universe(client_universe, credentials): | ||
| """Validate credentials immediately before making a network request. | ||
| Unlike ``google.api_core.universe.validate_credentials_universe`` (which | ||
| skips uncached Compute Engine credentials to avoid metadata server calls | ||
| during offline client initialization), this validates uncached Compute | ||
| Engine credentials as well before the outbound request is sent. | ||
| """ | ||
| if not HAS_UNIVERSE: | ||
| # Without google.api_core.universe (< 2.18.0), the client can only | ||
| # target the default universe; reject non-default credentials. | ||
| check_api_core_compatible_with_credentials_universe(credentials) | ||
| return | ||
| if credentials is None or isinstance(credentials, _ANONYMOUS_CREDENTIAL_TYPES): | ||
| return | ||
| # Intentionally call compare_domains directly rather than | ||
| # google.api_core.universe.validate_credentials_universe so uncached | ||
| # Compute Engine credentials are checked before attaching a token. | ||
| api_core_universe.compare_domains(client_universe, credentials) | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -53,16 +53,15 @@ | |||||||||||||||||||||
| except ImportError: # pragma: NO COVER | ||||||||||||||||||||||
| google_auth_httplib2 = None | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| try: | ||||||||||||||||||||||
| from google.api_core import universe | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| HAS_UNIVERSE = True | ||||||||||||||||||||||
| except ImportError: | ||||||||||||||||||||||
| HAS_UNIVERSE = False | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Local imports | ||||||||||||||||||||||
| from googleapiclient import _auth, mimeparse | ||||||||||||||||||||||
| from googleapiclient import _auth, _universe, mimeparse | ||||||||||||||||||||||
| from googleapiclient._helpers import _add_query_parameter, positional | ||||||||||||||||||||||
| from googleapiclient._universe import ( | ||||||||||||||||||||||
| DEFAULT_UNIVERSE, | ||||||||||||||||||||||
| GOOGLE_CLOUD_UNIVERSE_DOMAIN, | ||||||||||||||||||||||
| HAS_UNIVERSE, | ||||||||||||||||||||||
| APICoreVersionError, | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| from googleapiclient.errors import ( | ||||||||||||||||||||||
| HttpError, | ||||||||||||||||||||||
| InvalidJsonError, | ||||||||||||||||||||||
|
|
@@ -90,13 +89,15 @@ | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| URITEMPLATE = re.compile("{[^}]*}") | ||||||||||||||||||||||
| VARNAME = re.compile("[a-zA-Z0-9_-]+") | ||||||||||||||||||||||
| # Legacy V1 discovery is only supported in the default universe (googleapis.com). | ||||||||||||||||||||||
| DISCOVERY_URI = ( | ||||||||||||||||||||||
| "https://www.googleapis.com/discovery/v1/apis/" "{api}/{apiVersion}/rest" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| V1_DISCOVERY_URI = DISCOVERY_URI | ||||||||||||||||||||||
| V2_DISCOVERY_URI = ( | ||||||||||||||||||||||
| "https://{api}.googleapis.com/$discovery/rest?" "version={apiVersion}" | ||||||||||||||||||||||
| _V2_DISCOVERY_URI_TEMPLATE = ( | ||||||||||||||||||||||
| "https://{{api}}.{universe_domain}/$discovery/rest?version={{apiVersion}}" | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| V2_DISCOVERY_URI = _V2_DISCOVERY_URI_TEMPLATE.format(universe_domain=DEFAULT_UNIVERSE) | ||||||||||||||||||||||
| DEFAULT_METHOD_DOC = "A description of how to use this function" | ||||||||||||||||||||||
| HTTP_PAYLOAD_METHODS = frozenset(["PUT", "POST", "PATCH"]) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -123,22 +124,12 @@ | |||||||||||||||||||||
| # Parameters controlling mTLS behavior. See https://google.aip.dev/auth/4114. | ||||||||||||||||||||||
| GOOGLE_API_USE_CLIENT_CERTIFICATE = "GOOGLE_API_USE_CLIENT_CERTIFICATE" | ||||||||||||||||||||||
| GOOGLE_API_USE_MTLS_ENDPOINT = "GOOGLE_API_USE_MTLS_ENDPOINT" | ||||||||||||||||||||||
| GOOGLE_CLOUD_UNIVERSE_DOMAIN = "GOOGLE_CLOUD_UNIVERSE_DOMAIN" | ||||||||||||||||||||||
| DEFAULT_UNIVERSE = "googleapis.com" | ||||||||||||||||||||||
| # Parameters accepted by the stack, but not visible via discovery. | ||||||||||||||||||||||
| # TODO(dhermes): Remove 'userip' in 'v2'. | ||||||||||||||||||||||
| STACK_QUERY_PARAMETERS = frozenset(["trace", "pp", "userip", "strict"]) | ||||||||||||||||||||||
| STACK_QUERY_PARAMETER_DEFAULT_VALUE = {"type": "string", "location": "query"} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| class APICoreVersionError(ValueError): | ||||||||||||||||||||||
| def __init__(self): | ||||||||||||||||||||||
| message = ( | ||||||||||||||||||||||
| "google-api-core >= 2.18.0 is required to use the universe domain feature." | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| super().__init__(message) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Library-specific reserved words beyond Python keywords. | ||||||||||||||||||||||
| RESERVED_WORDS = frozenset(["body"]) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -222,7 +213,8 @@ def build( | |||||||||||||||||||||
| discoveryServiceUrl: string, a URI Template that points to the location of | ||||||||||||||||||||||
| the discovery service. It should have two parameters {api} and | ||||||||||||||||||||||
| {apiVersion} that when filled in produce an absolute URI to the discovery | ||||||||||||||||||||||
| document for that service. | ||||||||||||||||||||||
| document for that service. If not provided, the discovery service of the | ||||||||||||||||||||||
| client's universe domain is used. | ||||||||||||||||||||||
| developerKey: string, key obtained from | ||||||||||||||||||||||
| https://code.google.com/apis/console. | ||||||||||||||||||||||
| model: googleapiclient.Model, converts to and from the wire format. | ||||||||||||||||||||||
|
|
@@ -276,6 +268,13 @@ def build( | |||||||||||||||||||||
| Raises: | ||||||||||||||||||||||
| google.auth.exceptions.MutualTLSChannelError: if there are any problems | ||||||||||||||||||||||
| setting up mutual TLS channel. | ||||||||||||||||||||||
| google.api_core.universe.UniverseMismatchError: if `static_discovery` is | ||||||||||||||||||||||
| False and the credentials of `http` or `credentials` belong to a | ||||||||||||||||||||||
| different universe domain than the client. | ||||||||||||||||||||||
|
Comment on lines
+271
to
+273
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch |
||||||||||||||||||||||
| google.api_core.universe.EmptyUniverseError: if the configured universe | ||||||||||||||||||||||
| domain is empty. | ||||||||||||||||||||||
| googleapiclient.discovery.APICoreVersionError: if universe features | ||||||||||||||||||||||
| are configured with `google-api-core < 2.18.0`. | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
| params = {"api": serviceName, "apiVersion": version} | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
@@ -291,14 +290,31 @@ def build( | |||||||||||||||||||||
| else: | ||||||||||||||||||||||
| static_discovery = False | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Resolve the universe domain before any request is made, so that the | ||||||||||||||||||||||
| # discovery document is retrieved from the same universe as the API. | ||||||||||||||||||||||
| universe_domain = _universe.resolve_client_universe(client_options) | ||||||||||||||||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if not static_discovery: | ||||||||||||||||||||||
| # Validate any in-memory credentials before retrieving the discovery | ||||||||||||||||||||||
| # document over the network (raises UniverseMismatchError, or | ||||||||||||||||||||||
| # APICoreVersionError when google-api-core < 2.18.0). | ||||||||||||||||||||||
| credentials_to_validate = ( | ||||||||||||||||||||||
| getattr(http, "credentials", None) if http is not None else credentials | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| _universe.validate_request_credentials_universe( | ||||||||||||||||||||||
| universe_domain, credentials_to_validate | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if http is None: | ||||||||||||||||||||||
| discovery_http = build_http() | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| discovery_http = http | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| service = None | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| for discovery_url in _discovery_service_uri_options(discoveryServiceUrl, version): | ||||||||||||||||||||||
| for discovery_url in _discovery_service_uri_options( | ||||||||||||||||||||||
| discoveryServiceUrl, version, universe_domain | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
| requested_url = uritemplate.expand(discovery_url, params) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| try: | ||||||||||||||||||||||
|
|
@@ -344,7 +360,7 @@ def build( | |||||||||||||||||||||
| return service | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _discovery_service_uri_options(discoveryServiceUrl, version): | ||||||||||||||||||||||
| def _discovery_service_uri_options(discoveryServiceUrl, version, universe_domain=None): | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
| Returns Discovery URIs to be used for attempting to build the API Resource. | ||||||||||||||||||||||
|
|
@@ -353,13 +369,22 @@ def _discovery_service_uri_options(discoveryServiceUrl, version): | |||||||||||||||||||||
| string, the Original Discovery Service URL preferred by the customer. | ||||||||||||||||||||||
| version: | ||||||||||||||||||||||
| string, API Version requested | ||||||||||||||||||||||
| universe_domain: | ||||||||||||||||||||||
| string, the universe domain of the client. The default Discovery URIs | ||||||||||||||||||||||
| are returned for this universe domain. A non-empty | ||||||||||||||||||||||
| `discoveryServiceUrl` is returned unchanged. | ||||||||||||||||||||||
| Returns: | ||||||||||||||||||||||
| A list of URIs to be tried for the Service Discovery, in order. | ||||||||||||||||||||||
| """ | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if discoveryServiceUrl is not None: | ||||||||||||||||||||||
| return [discoveryServiceUrl] | ||||||||||||||||||||||
| if universe_domain and universe_domain != DEFAULT_UNIVERSE: | ||||||||||||||||||||||
| # Legacy V1 discovery (www.<domain>/discovery/v1/...) is only supported | ||||||||||||||||||||||
| # in the default universe; non-default universes serve discovery from | ||||||||||||||||||||||
| # the per-service V2 endpoint. | ||||||||||||||||||||||
| return [_V2_DISCOVERY_URI_TEMPLATE.format(universe_domain=universe_domain)] | ||||||||||||||||||||||
| if version is None: | ||||||||||||||||||||||
| # V1 Discovery won't work if the requested version is None | ||||||||||||||||||||||
| logger.warning( | ||||||||||||||||||||||
|
|
@@ -454,13 +479,6 @@ def _retrieve_discovery_doc( | |||||||||||||||||||||
| return content | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| def _check_api_core_compatible_with_credentials_universe(credentials): | ||||||||||||||||||||||
| if not HAS_UNIVERSE: | ||||||||||||||||||||||
| credentials_universe = getattr(credentials, "universe_domain", None) | ||||||||||||||||||||||
| if credentials_universe and credentials_universe != DEFAULT_UNIVERSE: | ||||||||||||||||||||||
| raise APICoreVersionError | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
|
|
||||||||||||||||||||||
| @positional(1) | ||||||||||||||||||||||
| def build_from_document( | ||||||||||||||||||||||
| service, | ||||||||||||||||||||||
|
|
@@ -569,17 +587,9 @@ def build_from_document( | |||||||||||||||||||||
|
|
||||||||||||||||||||||
| # If an API Endpoint is provided on client options, use that as the base URL | ||||||||||||||||||||||
| base = urllib.parse.urljoin(service["rootUrl"], service["servicePath"]) | ||||||||||||||||||||||
| universe_domain = None | ||||||||||||||||||||||
| if HAS_UNIVERSE: | ||||||||||||||||||||||
| universe_domain_env = os.getenv(GOOGLE_CLOUD_UNIVERSE_DOMAIN, None) | ||||||||||||||||||||||
| universe_domain = universe.determine_domain( | ||||||||||||||||||||||
| client_options.universe_domain, universe_domain_env | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| base = base.replace(universe.DEFAULT_UNIVERSE, universe_domain) | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| client_universe = getattr(client_options, "universe_domain", None) | ||||||||||||||||||||||
| if client_universe: | ||||||||||||||||||||||
| raise APICoreVersionError | ||||||||||||||||||||||
| universe_domain = _universe.resolve_client_universe(client_options) | ||||||||||||||||||||||
| if _universe.HAS_UNIVERSE: | ||||||||||||||||||||||
| base = base.replace(DEFAULT_UNIVERSE, universe_domain) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| audience_for_self_signed_jwt = base | ||||||||||||||||||||||
| if client_options.api_endpoint: | ||||||||||||||||||||||
|
|
@@ -620,7 +630,7 @@ def build_from_document( | |||||||||||||||||||||
| ) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # Check google-api-core >= 2.18.0 if credentials' universe != "googleapis.com". | ||||||||||||||||||||||
| _check_api_core_compatible_with_credentials_universe(credentials) | ||||||||||||||||||||||
| _universe.check_api_core_compatible_with_credentials_universe(credentials) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| # The credentials need to be scoped. | ||||||||||||||||||||||
| # If the user provided scopes via client_options don't override them | ||||||||||||||||||||||
|
|
@@ -713,15 +723,15 @@ def build_from_document( | |||||||||||||||||||||
| if use_mtls_endpoint == "always" or ( | ||||||||||||||||||||||
| use_mtls_endpoint == "auto" and client_cert_to_use | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
| if HAS_UNIVERSE and universe_domain != universe.DEFAULT_UNIVERSE: | ||||||||||||||||||||||
| if _universe.HAS_UNIVERSE and universe_domain != DEFAULT_UNIVERSE: | ||||||||||||||||||||||
| raise MutualTLSChannelError( | ||||||||||||||||||||||
| f"mTLS is not supported in any universe other than {universe.DEFAULT_UNIVERSE}." | ||||||||||||||||||||||
| f"mTLS is not supported in any universe other than {DEFAULT_UNIVERSE}." | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| base = mtls_endpoint | ||||||||||||||||||||||
| else: | ||||||||||||||||||||||
| # Check google-api-core >= 2.18.0 if credentials' universe != "googleapis.com". | ||||||||||||||||||||||
| http_credentials = getattr(http, "credentials", None) | ||||||||||||||||||||||
| _check_api_core_compatible_with_credentials_universe(http_credentials) | ||||||||||||||||||||||
| _universe.check_api_core_compatible_with_credentials_universe(http_credentials) | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| if model is None: | ||||||||||||||||||||||
| features = service.get("features", []) | ||||||||||||||||||||||
|
|
@@ -1413,7 +1423,7 @@ def __init__( | |||||||||||||||||||||
| resourceDesc, | ||||||||||||||||||||||
| rootDesc, | ||||||||||||||||||||||
| schema, | ||||||||||||||||||||||
| universe_domain=universe.DEFAULT_UNIVERSE if HAS_UNIVERSE else "", | ||||||||||||||||||||||
| universe_domain=DEFAULT_UNIVERSE if _universe.HAS_UNIVERSE else "", | ||||||||||||||||||||||
| ): | ||||||||||||||||||||||
| """Build a Resource from the API description. | ||||||||||||||||||||||
|
|
@@ -1630,9 +1640,11 @@ def _validate_credentials(self): | |||||||||||||||||||||
| self._credentials_validated = ( | ||||||||||||||||||||||
| ( | ||||||||||||||||||||||
| self._credentials_validated | ||||||||||||||||||||||
| or universe.compare_domains(self._universe_domain, credentials) | ||||||||||||||||||||||
| or _universe.api_core_universe.compare_domains( | ||||||||||||||||||||||
| self._universe_domain, credentials | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| if HAS_UNIVERSE | ||||||||||||||||||||||
| if _universe.HAS_UNIVERSE | ||||||||||||||||||||||
| else True | ||||||||||||||||||||||
| ) | ||||||||||||||||||||||
| return self._credentials_validated | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider stripping extra spaces from
options_universeandGOOGLE_CLOUD_UNIVERSE_DOMAINbefore checking them and callingdetermine_domain().That way, values with accidental spaces (like
" foo.com "or" ") behave the same way even on oldergoogle-api-corereleases (2.18.0–2.44.0), and"googleapis.com "won't accidentally triggerAPICoreVersionErrorwhenHAS_UNIVERSEisFalse.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added