From 804dc651b02e8bac6bf9d6454bb85998e4d67f78 Mon Sep 17 00:00:00 2001 From: javalladares Date: Thu, 21 Dec 2023 23:39:11 +0000 Subject: [PATCH] fix: issue #1441 Simplifying thoubleshooting by capturing last seen exception to set is as the direct cause of the `exceptions.TransportError` --- google/auth/compute_engine/_metadata.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/google/auth/compute_engine/_metadata.py b/google/auth/compute_engine/_metadata.py index 1c884c3c4..aedd45220 100644 --- a/google/auth/compute_engine/_metadata.py +++ b/google/auth/compute_engine/_metadata.py @@ -199,6 +199,7 @@ def get( url = _helpers.update_query(base_url, query_params) retries = 0 + last_exception = None while retries < retry_count: try: response = request(url=url, method="GET", headers=headers_to_use) @@ -213,11 +214,12 @@ def get( e, ) retries += 1 + last_exception = e else: raise exceptions.TransportError( "Failed to retrieve {} from the Google Compute Engine " "metadata service. Compute Engine Metadata server unavailable".format(url) - ) + ) from last_exception content = _helpers.from_bytes(response.data)