Skip to content

Conversation

@ohmayr
Copy link
Contributor

@ohmayr ohmayr commented Jan 23, 2025

GAPICs are designed to allow users to only configure one of transport or credentials. If a transport is configured explicitly, then it must be instantiated with credentials.

gapic-generator: See: https://github.com/googleapis/gapic-generator-python/blob/main/gapic/templates/%25namespace/%25name_%25version/%25sub/services/%25service/client.py.j2#L563.

pubsub: https://github.com/googleapis/python-pubsub/blob/main/google/pubsub_v1/services/publisher/client.py#L678

in google.cloud.pubsub_v1, if the environment variable PUBSUB_EMULATOR_HOST is set, the credentials are automatically set to AnonymousCredentials in the client layer.

This means that if PUBSUB_EMULATOR_HOST is set, then credentials are automatically configured under the hood for test cases.

This behaviour results in an issue if a test sets PUBSUB_EMULATOR_HOST explicitly and provides a transport to a client, resulting in the following error to be raised https://github.com/googleapis/python-pubsub/blob/main/google/pubsub_v1/services/publisher/client.py#L678.

Given that we want to update the following test to explicitly configure a transport to the client (with an intercept channel), we want to make sure that credentials are provided to the transport instance and not on the client instance directly.

@ohmayr ohmayr requested review from a team as code owners January 23, 2025 16:24
@product-auto-label product-auto-label bot added the size: xs Pull request size is extra small. label Jan 23, 2025
@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Jan 23, 2025
@ohmayr ohmayr force-pushed the set-creds-to-transport branch from 48a2676 to 0f09432 Compare January 23, 2025 16:29
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xs Pull request size is extra small. labels Jan 24, 2025
@ohmayr ohmayr force-pushed the set-creds-to-transport branch from 23d71e2 to 8f75047 Compare January 24, 2025 19:26
@ohmayr ohmayr requested a review from a team as a code owner January 24, 2025 22:49
@ohmayr ohmayr requested a review from nicain January 24, 2025 22:49
@product-auto-label product-auto-label bot added size: xl Pull request size is extra large. and removed size: s Pull request size is small. labels Jan 24, 2025
@ohmayr ohmayr force-pushed the set-creds-to-transport branch from 173957a to 361cacb Compare January 27, 2025 16:30
@product-auto-label product-auto-label bot added size: s Pull request size is small. and removed size: xl Pull request size is extra large. labels Jan 27, 2025
@mukund-ananthu mukund-ananthu merged commit 59965a4 into main Jan 29, 2025
27 checks passed
@mukund-ananthu mukund-ananthu deleted the set-creds-to-transport branch January 29, 2025 20:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: pubsub Issues related to the googleapis/python-pubsub API. size: s Pull request size is small.

3 participants