Skip to content

Commit 8c50755

Browse files
authored
fix: include role and service account in IAM exception (#1564)
1 parent af842b1 commit 8c50755

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

bigframes/clients.py

+7-2
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def create_bq_connection(
106106
)
107107
if service_account_id:
108108
logger.info(
109-
f"Connector {project_id}.{location}.{connection_id} already exists"
109+
f"BQ connection {project_id}.{location}.{connection_id} already exists"
110110
)
111111
else:
112112
connection_name, service_account_id = self._create_bq_connection(
@@ -116,9 +116,14 @@ def create_bq_connection(
116116
f"Created BQ connection {connection_name} with service account id: {service_account_id}"
117117
)
118118
service_account_id = cast(str, service_account_id)
119+
119120
# Ensure IAM role on the BQ connection
120121
# https://cloud.google.com/bigquery/docs/reference/standard-sql/remote-functions#grant_permission_on_function
121-
self._ensure_iam_binding(project_id, service_account_id, iam_role)
122+
try:
123+
self._ensure_iam_binding(project_id, service_account_id, iam_role)
124+
except google.api_core.exceptions.PermissionDenied as ex:
125+
ex.message = f"Failed ensuring IAM binding (role={iam_role}, service-account={service_account_id}). {ex.message}"
126+
raise
122127

123128
# Introduce retries to accommodate transient errors like:
124129
# (1) Etag mismatch,

0 commit comments

Comments
 (0)