diff --git a/packages/google-cloud-spanner/google/cloud/spanner_v1/session.py b/packages/google-cloud-spanner/google/cloud/spanner_v1/session.py index 308c5d323624..32fe74b5cc14 100644 --- a/packages/google-cloud-spanner/google/cloud/spanner_v1/session.py +++ b/packages/google-cloud-spanner/google/cloud/spanner_v1/session.py @@ -543,7 +543,9 @@ def run_in_transaction(self, func, *args, **kw): except Aborted as exc: previous_transaction_id = txn._transaction_id delay_seconds = _get_retry_delay( - exc.errors[0], attempts, default_retry_delay=default_retry_delay + exc.errors[0] if exc.errors else None, + attempts, + default_retry_delay=default_retry_delay, ) attributes = dict(delay_seconds=delay_seconds, cause=str(exc)) attributes.update(span_attributes) @@ -580,7 +582,9 @@ def run_in_transaction(self, func, *args, **kw): except Aborted as exc: previous_transaction_id = txn._transaction_id delay_seconds = _get_retry_delay( - exc.errors[0], attempts, default_retry_delay=default_retry_delay + exc.errors[0] if exc.errors else None, + attempts, + default_retry_delay=default_retry_delay, ) attributes = dict(delay_seconds=delay_seconds) attributes.update(span_attributes)