From 2c60077ae9ca124e87dc53be1c759a81ab074923 Mon Sep 17 00:00:00 2001 From: A Vertex SDK engineer Date: Mon, 31 Aug 2026 16:09:15 -0700 Subject: [PATCH] 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 --- agentplatform/_genai/sandboxes.py | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/agentplatform/_genai/sandboxes.py b/agentplatform/_genai/sandboxes.py index e5da4cf9f6..e92a46a05b 100644 --- a/agentplatform/_genai/sandboxes.py +++ b/agentplatform/_genai/sandboxes.py @@ -1038,7 +1038,14 @@ def pause( get_operation_fn=self._get_sandbox_operation, poll_interval_seconds=poll_interval_seconds, ) - if operation.response: + # Only refresh via get() when the LRO response carries a resource + # name. The pause LRO's response_type is declared as SandboxEnvironment + # in the proto but the backend may return an empty payload for some + # code paths, in which case operation.response.name is empty and a + # get() call would produce a 404 with an unsubstituted {name} in the + # request URL. Callers who want the post-pause state can call + # sandboxes.get(name=name) explicitly. + if operation.response and getattr(operation.response, "name", None): operation.response = self.get(name=operation.response.name) return operation @@ -1084,7 +1091,11 @@ def resume( get_operation_fn=self._get_sandbox_operation, poll_interval_seconds=poll_interval_seconds, ) - if operation.response: + # Only refresh via get() when the LRO response carries a resource + # name. Symmetric guard with pause() above: protects against a backend + # response payload without a name field, which would otherwise produce + # a 404 with an unsubstituted {name} in the request URL. + if operation.response and getattr(operation.response, "name", None): operation.response = self.get(name=operation.response.name) return operation