diff --git a/.changeset/witty-parrots-decide.md b/.changeset/witty-parrots-decide.md new file mode 100644 index 0000000000..8b7793a719 --- /dev/null +++ b/.changeset/witty-parrots-decide.md @@ -0,0 +1,6 @@ +--- +'e2b': patch +'@e2b/python-sdk': patch +--- + +Remove client-side validation of the fork `count` argument. The API validates the requested fork count and rejects invalid values. diff --git a/packages/js-sdk/src/sandbox/sandboxApi.ts b/packages/js-sdk/src/sandbox/sandboxApi.ts index 3af6b1bace..0b56e3bbd9 100644 --- a/packages/js-sdk/src/sandbox/sandboxApi.ts +++ b/packages/js-sdk/src/sandbox/sandboxApi.ts @@ -1709,10 +1709,6 @@ export class SandboxApi extends ClientFactory { count: number, opts?: SandboxApiOpts ): Promise { - if (count < 1) { - throw new InvalidArgumentError('count must be at least 1') - } - const apiOpts = this.resolveOpts(opts) const config = new ConnectionConfig(apiOpts) const client = new ApiClient(config) diff --git a/packages/js-sdk/tests/sandbox/fork.test.ts b/packages/js-sdk/tests/sandbox/fork.test.ts index da3d30b9a6..20e8a227a7 100644 --- a/packages/js-sdk/tests/sandbox/fork.test.ts +++ b/packages/js-sdk/tests/sandbox/fork.test.ts @@ -1,8 +1,8 @@ import { assert, expect, test } from 'vitest' -import { sandboxTest, isDebug, TEST_API_KEY } from '../setup.js' +import { sandboxTest, isDebug } from '../setup.js' import { Sandbox } from '../../src' -import { InvalidArgumentError, SandboxNotFoundError } from '../../src/errors' +import { SandboxNotFoundError } from '../../src/errors' sandboxTest.skipIf(isDebug)('fork a sandbox', async ({ sandbox }) => { await sandbox.files.write('/home/user/state.txt', 'state before fork') @@ -86,9 +86,3 @@ test.skipIf(isDebug)('fork a killed sandbox fails', async () => { await expect(sandbox.fork()).rejects.toThrowError(SandboxNotFoundError) }) - -test('fork with count lower than 1 fails', async () => { - await expect( - Sandbox.fork('sbx-test', { count: 0, apiKey: TEST_API_KEY }) - ).rejects.toThrowError(InvalidArgumentError) -}) diff --git a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py index b6a208d6a8..dd8e61d3b2 100644 --- a/packages/python-sdk/e2b/sandbox_async/sandbox_api.py +++ b/packages/python-sdk/e2b/sandbox_async/sandbox_api.py @@ -39,7 +39,6 @@ from e2b.api.client_async import get_api_client from e2b.connection_config import ApiParams, ConnectionConfig from e2b.exceptions import ( - InvalidArgumentException, NotFoundException, SandboxException, SandboxNotFoundException, @@ -447,9 +446,6 @@ async def _cls_fork( ) count = count if count is not None else 1 - if count < 1: - raise InvalidArgumentException("count must be at least 1") - config = ConnectionConfig(logger=logger, **cls._resolve_api_params(**opts)) api_client = get_api_client(config) diff --git a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py index ff8dc4a3e8..5114d69e1c 100644 --- a/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py +++ b/packages/python-sdk/e2b/sandbox_sync/sandbox_api.py @@ -38,7 +38,6 @@ from e2b.api.client.types import UNSET, Unset from e2b.connection_config import ApiParams, ConnectionConfig from e2b.exceptions import ( - InvalidArgumentException, NotFoundException, SandboxException, SandboxNotFoundException, @@ -400,9 +399,6 @@ def _cls_fork( ) count = count if count is not None else 1 - if count < 1: - raise InvalidArgumentException("count must be at least 1") - config = ConnectionConfig(logger=logger, **cls._resolve_api_params(**opts)) api_client = get_api_client(config) diff --git a/packages/python-sdk/tests/async/sandbox_async/test_fork.py b/packages/python-sdk/tests/async/sandbox_async/test_fork.py index 19f8c7ef23..ab15402dc7 100644 --- a/packages/python-sdk/tests/async/sandbox_async/test_fork.py +++ b/packages/python-sdk/tests/async/sandbox_async/test_fork.py @@ -1,7 +1,7 @@ import pytest from e2b import AsyncSandbox -from e2b.exceptions import InvalidArgumentException, SandboxNotFoundException +from e2b.exceptions import SandboxNotFoundException @pytest.mark.skip_debug() @@ -76,8 +76,3 @@ async def test_fork_killed_sandbox(async_sandbox_factory): with pytest.raises(SandboxNotFoundException): await sandbox.fork() - - -async def test_fork_invalid_count(): - with pytest.raises(InvalidArgumentException): - await AsyncSandbox.fork("sbx-test", count=0) diff --git a/packages/python-sdk/tests/sync/sandbox_sync/test_fork.py b/packages/python-sdk/tests/sync/sandbox_sync/test_fork.py index 7159a53102..903431591b 100644 --- a/packages/python-sdk/tests/sync/sandbox_sync/test_fork.py +++ b/packages/python-sdk/tests/sync/sandbox_sync/test_fork.py @@ -1,7 +1,7 @@ import pytest from e2b import Sandbox -from e2b.exceptions import InvalidArgumentException, SandboxNotFoundException +from e2b.exceptions import SandboxNotFoundException @pytest.mark.skip_debug() @@ -73,8 +73,3 @@ def test_fork_killed_sandbox(sandbox_factory): with pytest.raises(SandboxNotFoundException): sandbox.fork() - - -def test_fork_invalid_count(): - with pytest.raises(InvalidArgumentException): - Sandbox.fork("sbx-test", count=0)