Skip to content

Commit 2c60077

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
fix: Guard the post-LRO refresh in sandboxes.pause() and sandboxes.resume() on the presence of a resource name in the LRO response.
PiperOrigin-RevId: 974131158
1 parent 5e9823f commit 2c60077

1 file changed

Lines changed: 13 additions & 2 deletions

File tree

‎agentplatform/_genai/sandboxes.py‎

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1038,7 +1038,14 @@ def pause(
10381038
get_operation_fn=self._get_sandbox_operation,
10391039
poll_interval_seconds=poll_interval_seconds,
10401040
)
1041-
if operation.response:
1041+
# Only refresh via get() when the LRO response carries a resource
1042+
# name. The pause LRO's response_type is declared as SandboxEnvironment
1043+
# in the proto but the backend may return an empty payload for some
1044+
# code paths, in which case operation.response.name is empty and a
1045+
# get() call would produce a 404 with an unsubstituted {name} in the
1046+
# request URL. Callers who want the post-pause state can call
1047+
# sandboxes.get(name=name) explicitly.
1048+
if operation.response and getattr(operation.response, "name", None):
10421049
operation.response = self.get(name=operation.response.name)
10431050
return operation
10441051

@@ -1084,7 +1091,11 @@ def resume(
10841091
get_operation_fn=self._get_sandbox_operation,
10851092
poll_interval_seconds=poll_interval_seconds,
10861093
)
1087-
if operation.response:
1094+
# Only refresh via get() when the LRO response carries a resource
1095+
# name. Symmetric guard with pause() above: protects against a backend
1096+
# response payload without a name field, which would otherwise produce
1097+
# a 404 with an unsubstituted {name} in the request URL.
1098+
if operation.response and getattr(operation.response, "name", None):
10881099
operation.response = self.get(name=operation.response.name)
10891100
return operation
10901101

0 commit comments

Comments
 (0)