fix: Handle TransportError Exceptions thrown from gapic_publish#1318
Merged
mukund-ananthu merged 1 commit intomainfrom Jan 6, 2025
Merged
fix: Handle TransportError Exceptions thrown from gapic_publish#1318mukund-ananthu merged 1 commit intomainfrom
mukund-ananthu merged 1 commit intomainfrom
Conversation
hongalex
approved these changes
Jan 6, 2025
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.
Current behavior:
If
TransportErroris thrown bygoogle.authlibrary:https://github.com/googleapis/google-auth-library-python/blob/c3ea09fd8b9ee8f094263fdc809c59d9dfaa3124/google/auth/compute_engine/_metadata.py#L187-L189
when doing a
_gapic_publish:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 322 to 327 in f79d35a
Then,
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 345 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 348 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 364 to 369 in f79d35a
gapic_publishwas occuring dies without setting the correct batch state / future exceptions:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 237 to 239 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 288 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 449 to 450 in f79d35a
python-pubsub/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py
Lines 323 to 326 in f79d35a
Behavior expected with change
TransportErrorduringgapic_publishwill be caught in addition to the existingGoogleAPIErrorpython-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Line 345 in f79d35a
GoogleAPIErroris caught duringgapic_publishwould also now apply toTransportError, i.e:ERROR, future exceptions will be set:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 345 to 371 in f79d35a
AssertionError:python-pubsub/google/cloud/pubsub_v1/publisher/_batch/thread.py
Lines 444 to 447 in f79d35a
which will be bubbled up through the Ordered / Unordered Sequenceer's
publishmethod:python-pubsub/google/cloud/pubsub_v1/publisher/_sequencer/ordered_sequencer.py
Lines 321 to 328 in f79d35a
to the Publisher client's
publishmethod:python-pubsub/google/cloud/pubsub_v1/publisher/client.py
Lines 477 to 495 in f79d35a
which would bubble the exception back to the user
Additional details can be found here: #1173 (comment)
Fixes #1173 🦕