Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changeset/witty-parrots-decide.md
Original file line number Diff line number Diff line change
@@ -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.
4 changes: 0 additions & 4 deletions packages/js-sdk/src/sandbox/sandboxApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1709,10 +1709,6 @@ export class SandboxApi extends ClientFactory {
count: number,
opts?: SandboxApiOpts
): Promise<SandboxForkResponse[]> {
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)
Expand Down
10 changes: 2 additions & 8 deletions packages/js-sdk/tests/sandbox/fork.test.ts
Original file line number Diff line number Diff line change
@@ -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')
Expand Down Expand Up @@ -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)
})
4 changes: 0 additions & 4 deletions packages/python-sdk/e2b/sandbox_async/sandbox_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions packages/python-sdk/e2b/sandbox_sync/sandbox_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)
7 changes: 1 addition & 6 deletions packages/python-sdk/tests/sync/sandbox_sync/test_fork.py
Original file line number Diff line number Diff line change
@@ -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()
Expand Down Expand Up @@ -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)
Loading