Skip to content
This repository was archived by the owner on Mar 31, 2026. It is now read-only.
2 changes: 2 additions & 0 deletions google/cloud/storage/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,8 @@ def is_etag_in_json(data):

Indended for use on calls with relatively short JSON payloads."""
try:
if isinstance(data, dict) and data.get("etag"):
Comment thread
cojenco marked this conversation as resolved.
Outdated
return True
content = json.loads(data)
if content.get("etag"):
return True
Expand Down
5 changes: 5 additions & 0 deletions tests/unit/test_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,11 @@ def test_w_empty_data(self):

self.assertFalse(self._call_fut(data))

def test_w_etag_in_dict(self):
data = {"etag": "123"}

self.assertTrue(self._call_fut(data))


class Test_default_conditional_retry_policies(unittest.TestCase):
def test_is_generation_specified_match_generation_match(self):
Expand Down