Skip to content

Commit 879daad

Browse files
authored
validate sandbox names on sandbox create and restore (#3727)
1 parent d67c0a5 commit 879daad

File tree

1 file changed

+3
-13
lines changed

1 file changed

+3
-13
lines changed

modal/sandbox.py

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from ._utils.async_utils import TaskContext, synchronize_api
3030
from ._utils.deprecation import deprecation_warning
3131
from ._utils.mount_utils import validate_network_file_systems, validate_volumes
32-
from ._utils.name_utils import is_valid_object_name
32+
from ._utils.name_utils import check_object_name
3333
from ._utils.task_command_router_client import TaskCommandRouterClient
3434
from .client import _Client
3535
from .container_process import _ContainerProcess
@@ -79,16 +79,6 @@ def _validate_exec_args(args: Sequence[str]) -> None:
7979
)
8080

8181

82-
def _warn_if_invalid_name(name: str) -> None:
83-
if not is_valid_object_name(name):
84-
deprecation_warning(
85-
(2025, 9, 3),
86-
f"Sandbox name '{name}' will be considered invalid in a future release."
87-
"\n\nNames may contain only alphanumeric characters, dashes, periods, and underscores,"
88-
" must be shorter than 64 characters, and cannot conflict with App ID strings.",
89-
)
90-
91-
9282
class DefaultSandboxNameOverride(str):
9383
"""A singleton class that represents the default sandbox name override.
9484
@@ -440,7 +430,7 @@ async def _create(
440430

441431
_validate_exec_args(args)
442432
if name is not None:
443-
_warn_if_invalid_name(name)
433+
check_object_name(name, "Sandbox")
444434

445435
if block_network and (encrypted_ports or h2_ports or unencrypted_ports):
446436
raise InvalidError("Cannot specify open ports when `block_network` is enabled")
@@ -1020,7 +1010,7 @@ async def _experimental_from_snapshot(
10201010
client = client or await _Client.from_env()
10211011

10221012
if name is not None and name != _DEFAULT_SANDBOX_NAME_OVERRIDE:
1023-
_warn_if_invalid_name(name)
1013+
check_object_name(name, "Sandbox")
10241014

10251015
if name is _DEFAULT_SANDBOX_NAME_OVERRIDE:
10261016
restore_req = api_pb2.SandboxRestoreRequest(

0 commit comments

Comments
 (0)