From 243ca19c2b71c2fe1be727cba878ae7e6703eae3 Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Mon, 27 Jul 2026 15:27:20 -0700 Subject: [PATCH] fix: Send display_name when creating a sandbox environment template. The `display_name` parameter of the sandbox template create method was routed with `_parent.*`, but it is a top-level request parameter with no parent object, so it was silently dropped from the request body (never sent to the backend). Route it to the request body (`*`) so `display_name` is correctly included. PiperOrigin-RevId: 954860747 --- agentplatform/_genai/sandbox_templates.py | 2 +- .../replays/test_ae_sandbox_templates_byoc_create.py | 12 ++++++++++++ .../test_ae_sandbox_templates_default_create.py | 11 +++++++++++ 3 files changed, 24 insertions(+), 1 deletion(-) 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__,