fix(ci): import profiler ci setuptools - #17713
Conversation
…rs.py Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…al client_helpers methods
Splits the monolithic client_helpers.py into routing.py, client_cert.py, config_helpers.py, and method_helpers.py to improve readability and maintainability. Updates gapic_v1 exports and test imports accordingly.
…and enable REST tests without grpc
…re_deps_from_source in noxfile
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
…ers.py Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
Co-authored-by: Anthonios Partheniou <partheniou@google.com>
…n-grpc environments
There was a problem hiding this comment.
Code Review
This pull request introduces several helper modules under google/api_core/gapic_v1 to handle client certificates, environment variable parsing, request ID generation, and routing/endpoint resolution for mTLS and universe domains, along with comprehensive unit tests. The feedback suggests raising a MutualTLSChannelError in _get_client_cert_source if mTLS is enabled but no client certificate source is provided or found, rather than silently falling back to standard TLS.
| client_cert_source = None | ||
| if use_cert_flag: | ||
| if provided_cert_source: | ||
| client_cert_source = provided_cert_source | ||
| elif ( | ||
| hasattr(mtls, "has_default_client_cert_source") | ||
| and mtls.has_default_client_cert_source() | ||
| ): | ||
| client_cert_source = mtls.default_client_cert_source() | ||
| return client_cert_source |
There was a problem hiding this comment.
According to the general rules, we should not silently fall back to standard TLS if mutual TLS (mTLS) configuration or certificate loading fails. If use_cert_flag is True but no client certificate source can be found (neither provided nor default), we should raise a MutualTLSChannelError to fail fast and avoid security risks or confusing downstream authorization errors.
| client_cert_source = None | |
| if use_cert_flag: | |
| if provided_cert_source: | |
| client_cert_source = provided_cert_source | |
| elif ( | |
| hasattr(mtls, "has_default_client_cert_source") | |
| and mtls.has_default_client_cert_source() | |
| ): | |
| client_cert_source = mtls.default_client_cert_source() | |
| return client_cert_source | |
| client_cert_source = None | |
| if use_cert_flag: | |
| if provided_cert_source: | |
| client_cert_source = provided_cert_source | |
| elif ( | |
| hasattr(mtls, "has_default_client_cert_source") | |
| and mtls.has_default_client_cert_source() | |
| ): | |
| client_cert_source = mtls.default_client_cert_source() | |
| else: | |
| from google.auth.exceptions import MutualTLSChannelError | |
| raise MutualTLSChannelError( | |
| "Client certificate source is required when mTLS is enabled, " | |
| "but no client certificate source was provided or found." | |
| ) | |
| return client_cert_source |
References
- Do not silently fall back to standard TLS if mutual TLS (mTLS) configuration or certificate loading fails. Silently falling back can introduce security vulnerabilities or cause confusing downstream authorization errors; instead, fail fast by raising an appropriate exception.
Error
The import-profile CI workflow fails on Python 3.15 with:
This PR installs setuptools inside the temporary .venv-profiler virtualenv created for profiling. This ensures the profiler's namespace package resolution logic works correctly on newer Python versions (3.12+) where setuptools is no longer installed by default.