Skip to content
This repository was archived by the owner on Oct 1, 2026. It is now read-only.

Fix region enum mapping for ADK deployments - #43

Merged
HemasumanthDO merged 2 commits into
digitalocean:mainfrom
HemasumanthDO:hema/add-region-to-adk-deploy
Apr 18, 2026
Merged

HemasumanthDO merged 2 commits into
digitalocean:mainfrom
HemasumanthDO:hema/add-region-to-adk-deploy

Conversation

@HemasumanthDO

Copy link
Copy Markdown
Collaborator

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

  • Deploy with region: atl1 in config, verify API response shows ATL1 region
  • Deploy with no region, verify default behavior unchanged

Made with Cursor

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines 323 to 332
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:

Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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.

Copilot uses AI. Check for mistakes.
Comment on lines +41 to +43
return f"AGENT_WORKSPACE_DEPLOYMENT_REGION_{region.upper()}"


Copilot AI Apr 18, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_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.

Suggested change
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}"

Copilot uses AI. Check for mistakes.
@HemasumanthDO
HemasumanthDO requested a review from jshah-do April 18, 2026 03:07
@HemasumanthDO
HemasumanthDO merged commit 08e177b into digitalocean:main Apr 18, 2026
5 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants