Skip to content

Commit b87105c

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
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: 952240948
1 parent 475024c commit b87105c

3 files changed

Lines changed: 24 additions & 1 deletion

File tree

agentplatform/_genai/sandbox_templates.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def _CreateSandboxEnvironmentTemplateRequestParameters_to_vertex(
7979
)
8080

8181
if getv(from_object, ["display_name"]) is not None:
82-
setv(parent_object, ["displayName"], getv(from_object, ["display_name"]))
82+
setv(to_object, ["displayName"], getv(from_object, ["display_name"]))
8383

8484
return to_object
8585

tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_byoc_create.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,18 @@ def test_sandbox_templates_byoc_create(client):
5959
sandbox_template_operation, types.SandboxEnvironmentTemplateOperation
6060
)
6161

62+
# Verify display_name is sent in the create request body. The replay client
63+
# asserts the SDK's actual request matches this recorded request, so checking
64+
# the recorded body confirms display_name is included rather than dropped
65+
# (the behavior this CL fixes). interactions[0] is the create POST; later
66+
# interactions are the operation polls from create() waiting on the LRO.
67+
client._api_client._initialize_replay_session_if_not_loaded()
68+
if client._api_client.replay_session:
69+
create_request_body = client._api_client.replay_session.interactions[
70+
0
71+
].request.body_segments[0]
72+
assert create_request_body["displayName"] == "Test Sandbox Template 1"
73+
6274

6375
pytestmark = pytest_helper.setup(
6476
file=__file__,

tests/unit/agentplatform/genai/replays/test_ae_sandbox_templates_default_create.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,17 @@ def test_sandbox_templates_default_create(client):
3838
sandbox_template_operation, types.SandboxEnvironmentTemplateOperation
3939
)
4040

41+
# Verify display_name is sent in the create request body. The replay client
42+
# asserts the SDK's actual request matches this recorded request, so checking
43+
# the recorded body confirms display_name is included rather than dropped
44+
# (the behavior this CL fixes).
45+
client._api_client._initialize_replay_session_if_not_loaded()
46+
if client._api_client.replay_session:
47+
create_request_body = client._api_client.replay_session.interactions[
48+
0
49+
].request.body_segments[0]
50+
assert create_request_body["displayName"] == "Test Sandbox Template 1"
51+
4152

4253
pytestmark = pytest_helper.setup(
4354
file=__file__,

0 commit comments

Comments
 (0)