Skip to content

Commit 746b916

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: Make project_number to project_id mapping fail-open.
Fixes regression when deploying with IdentityType.AGENT_IDENTIY FUTURE_COPYBARA_INTEGRATE_REVIEW=#6207 from googleapis:release-please--branches--main 95b8d4f PiperOrigin-RevId: 846233944
1 parent 64cc464 commit 746b916

File tree

2 files changed

+18
-4
lines changed
  • vertexai
    • agent_engines/templates
    • preview/reasoning_engines/templates

2 files changed

+18
-4
lines changed

vertexai/agent_engines/templates/adk.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,8 +1654,15 @@ def _warn_if_telemetry_api_disabled(self):
16541654

16551655
def project_id(self) -> Optional[str]:
16561656
if project := self._tmpl_attrs.get("project"):
1657-
from google.cloud.aiplatform.utils import resource_manager_utils
1657+
try:
1658+
from google.cloud.aiplatform.utils import (
1659+
resource_manager_utils,
1660+
)
1661+
from google.api_core import exceptions
16581662

1659-
return resource_manager_utils.get_project_id(project)
1663+
return resource_manager_utils.get_project_id(project)
1664+
# Fail open as temporary workaround for identity_type config parameter
1665+
except (exceptions.PermissionDenied, exceptions.Unauthenticated):
1666+
return project
16601667

16611668
return None

vertexai/preview/reasoning_engines/templates/adk.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1561,8 +1561,15 @@ def _warn_if_telemetry_api_disabled(self):
15611561

15621562
def project_id(self) -> Optional[str]:
15631563
if project := self._tmpl_attrs.get("project"):
1564-
from google.cloud.aiplatform.utils import resource_manager_utils
1564+
try:
1565+
from google.cloud.aiplatform.utils import (
1566+
resource_manager_utils,
1567+
)
1568+
from google.api_core import exceptions
15651569

1566-
return resource_manager_utils.get_project_id(project)
1570+
return resource_manager_utils.get_project_id(project)
1571+
# Fail open as temporary workaround for identity_type config parameter
1572+
except (exceptions.PermissionDenied, exceptions.Unauthenticated):
1573+
return project
15671574

15681575
return None

0 commit comments

Comments
 (0)