Repository navigation
fix(gapic-generator): forward client_options to Extended Operations sub-clients - #19293
Draft
chalmerlowe wants to merge 5 commits into
Draft
chalmerlowe wants to merge 5 commits into
chalmerlowe wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request updates the GAPIC generator templates to support propagating client options, such as universe domains and API endpoints, to extended operations sub-clients, including a fallback compatibility implementation for older google-api-core versions and extensive unit tests. The review feedback highlights a critical missing import of client_options_lib in the base transport template that would cause a runtime NameError, as well as a recommended improvement to use getattr when checking credentials_file to prevent potential AttributeErrors.
…for credentials_file
…ded-ops universe forwarding
…rom _compat to transports/base
… move exhaustive helper matrix to generator unit tests
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Generated Extended Operations sub-client properties (
_zone_operations_client,_region_operations_client,_global_operations_client,_global_organization_operations_client) previously instantiated their operations clients with onlycredentialsandtransport, dropping parentclient_options(includinguniverse_domain,api_endpoint,api_audience,client_cert_source,scopes, andquota_project_id). As a result, polling anExtendedOperationon a client configured for a customuniverse_domainorapi_endpointrouted operation polling back to the defaultgoogleapis.comendpoint.This PR updates the
gapic-generatortemplates (~216 lines of production template changes + two-tier tests) so Extended Operations sub-clients inheritclient_optionsfrom the parent client:transports/base.py.j2: Defines_inherit_universe_in_client_options(gated on Extended Operations services) withchild.api_endpoint -> child.universe_domain -> parent.api_endpoint -> parent.universe_domain -> GOOGLE_CLOUD_UNIVERSE_DOMAIN -> defaultprecedence, clearingcredentials_fileandapi_keywhen forwarding alongside already-resolvedcredentialsto avoidDuplicateCredentialArgs, without mutating caller inputs. Preserves normalizedclient_optionson the transport and passes them when lazily constructing Extended Operations sub-clients.client.py.j2: Forwards normalizedclient_optionsonto both newly instantiated and prebuilt transports (safely guarding custom/duck-typed transports). Non-Extended-Operations services produce zero generated diff.test_%service.py.j2: Adds a lean per-service test suite (~310 lines) hitting 100% branch coverage on generatedclient.pyandtransports/base.pywithout bloating regenerated multi-service libraries likegoogle-cloud-compute.tests/unit/generator/test_extended_ops_universe.py: Runs the exhaustive_inherit_universe_in_client_optionsboundary/mutation matrix and non-Extended-Operations template-isolation checks once ingapic-generatorunit tests.Follow-up PR will regenerate
google-cloud-compute,google-cloud-compute-v1beta, andpreview-packages/google-cloud-computeonce this generator change lands.Internal tracking:
b/589828846