diff --git a/agentplatform/_genai/sandbox_templates.py b/agentplatform/_genai/sandbox_templates.py index 557cd7411e..a503195be4 100644 --- a/agentplatform/_genai/sandbox_templates.py +++ b/agentplatform/_genai/sandbox_templates.py @@ -79,7 +79,7 @@ def _CreateSandboxEnvironmentTemplateRequestParameters_to_vertex( ) if getv(from_object, ["display_name"]) is not None: - setv(parent_object, ["displayName"], getv(from_object, ["display_name"])) + setv(to_object, ["displayName"], getv(from_object, ["display_name"])) return to_object diff --git a/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_byoc_create.py b/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_byoc_create.py index 47d686b972..30ec57efb4 100644 --- a/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_byoc_create.py +++ b/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_byoc_create.py @@ -59,6 +59,18 @@ def test_sandbox_templates_byoc_create(client): sandbox_template_operation, types.SandboxEnvironmentTemplateOperation ) + # Verify display_name is sent in the create request body. The replay client + # asserts the SDK's actual request matches this recorded request, so checking + # the recorded body confirms display_name is included rather than dropped + # (the behavior this CL fixes). interactions[0] is the create POST; later + # interactions are the operation polls from create() waiting on the LRO. + client._api_client._initialize_replay_session_if_not_loaded() + if client._api_client.replay_session: + create_request_body = client._api_client.replay_session.interactions[ + 0 + ].request.body_segments[0] + assert create_request_body["displayName"] == "Test Sandbox Template 1" + pytestmark = pytest_helper.setup( file=__file__, diff --git a/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_default_create.py b/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_default_create.py index f1356297ad..60087195dc 100644 --- a/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_default_create.py +++ b/tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_default_create.py @@ -38,6 +38,17 @@ def test_sandbox_templates_default_create(client): sandbox_template_operation, types.SandboxEnvironmentTemplateOperation ) + # Verify display_name is sent in the create request body. The replay client + # asserts the SDK's actual request matches this recorded request, so checking + # the recorded body confirms display_name is included rather than dropped + # (the behavior this CL fixes). + client._api_client._initialize_replay_session_if_not_loaded() + if client._api_client.replay_session: + create_request_body = client._api_client.replay_session.interactions[ + 0 + ].request.body_segments[0] + assert create_request_body["displayName"] == "Test Sandbox Template 1" + pytestmark = pytest_helper.setup( file=__file__,