GeezerVison is showing github.com — fix: Make project_number to project_id mapping fail-open. · silverdev/python-aiplatform@f1c8458
File tree
Expand file treeCollapse file tree
Open diff view settings
preview/reasoning_engines/templates
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: vertexai/agent_engines/templates/adk.py +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1654,8 +1654,15 @@ def _warn_if_telemetry_api_disabled(self): |
1654 | 1654 |
|
1655 | 1655 | def project_id(self) -> Optional[str]: |
1656 | 1656 | 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 |
1658 | 1662 |
|
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 |
1660 | 1667 |
|
1661 | 1668 | return None |
Collapse file
Copy file name to clipboardExpand all lines: vertexai/preview/reasoning_engines/templates/adk.py +9-2Lines changed: 9 additions & 2 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -1561,8 +1561,15 @@ def _warn_if_telemetry_api_disabled(self): |
1561 | 1561 |
|
1562 | 1562 | def project_id(self) -> Optional[str]: |
1563 | 1563 | 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 |
1565 | 1569 |
|
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 |
1567 | 1574 |
|
1568 | 1575 | return None |