Repository navigation
Fix region enum mapping for ADK deployments - #43
HemasumanthDO merged 2 commits into
Conversation
Made-with: Cursor
There was a problem hiding this comment.
Pull request overview
This PR fixes how ADK deployment region is serialized when calling the API by converting user-friendly short region codes (e.g. atl1) into the fully-qualified proto enum string expected by the backend (e.g. AGENT_WORKSPACE_DEPLOYMENT_REGION_ATL1), preventing the backend from ignoring the region and defaulting.
Changes:
- Add a
_region_to_proto_enum()helper to translate short region strings into proto enum names. - Apply the translation when creating agent workspaces and deployments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| async def _create_or_update_deployment( | ||
| self, | ||
| workspace_exists: bool, | ||
| deployment_exists: bool, | ||
| agent_workspace_name: str, | ||
| agent_deployment_name: str, | ||
| code_artifact: AgentDeploymentCodeArtifact, | ||
| project_id: str, | ||
| description: str | None = None, | ||
| region: str | None = None, | ||
| ) -> str: |
There was a problem hiding this comment.
_create_or_update_deployment no longer accepts a region parameter, but callers still pass region=... and the function body references region. This will raise a TypeError (unexpected keyword argument) or NameError at runtime. Add region: str | None = None back to the function signature (and include it in the docstring args) so _region_to_proto_enum(region) has a defined value, or remove the keyword argument and any usage if region is no longer supported here.
| return f"AGENT_WORKSPACE_DEPLOYMENT_REGION_{region.upper()}" | ||
|
|
||
|
|
There was a problem hiding this comment.
_region_to_proto_enum() will produce an invalid enum name for inputs like an empty string or whitespace (e.g. "" -> AGENT_WORKSPACE_DEPLOYMENT_REGION_). Since config loading doesn’t validate/normalize region, consider stripping whitespace and treating empty strings as None, and/or detecting already-fully-qualified enum values (starting with AGENT_WORKSPACE_DEPLOYMENT_REGION_) to avoid double-prefixing.
| return f"AGENT_WORKSPACE_DEPLOYMENT_REGION_{region.upper()}" | |
| normalized_region = region.strip() | |
| if not normalized_region: | |
| return None | |
| enum_prefix = "AGENT_WORKSPACE_DEPLOYMENT_REGION_" | |
| upper_region = normalized_region.upper() | |
| if upper_region.startswith(enum_prefix): | |
| return upper_region | |
| return f"{enum_prefix}{upper_region}" |
Summary
Fix the region value sent to the API. The proto expects the full enum name (e.g.
AGENT_WORKSPACE_DEPLOYMENT_REGION_ATL1) not the short string (atl1). Without this fix, the region is ignored and defaults to the base region.Follow-up to #42.
Test plan
region: atl1in config, verify API response shows ATL1 regionMade with Cursor