-
Notifications
You must be signed in to change notification settings - Fork 1k
Remove SDK-side defaults from API request payloads #1749
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
devin-ai-integration
wants to merge
10
commits into
main
Choose a base branch
from
devin/1787318715-remove-sdk-defaults
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 7 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
1c4dc53
Remove SDK-side defaults from API request payloads
devin-ai-integration[bot] b92ce2b
Fix ruff formatting in test_api_defaults.py
devin-ai-integration[bot] 996c679
Keep SDK-side secure=true default for sandbox creation
devin-ai-integration[bot] ef24b64
Remove redundant API-default doc mentions
devin-ai-integration[bot] b984e34
fix(sdk): match JS and Python on malformed and null egress proxy input
mishushakov 6d991cb
Revert "fix(sdk): match JS and Python on malformed and null egress pr…
devin-ai-integration[bot] aa59e1f
Pin explicit 300s timeout in test sandbox fixtures
devin-ai-integration[bot] e4d7b95
Address review: add template build payload tests, mirror connect time…
devin-ai-integration[bot] a06670b
Drop SDK-side connect timeout and secure defaults
devin-ai-integration[bot] e9963a5
Remove client-side fork count validation per T-52
devin-ai-integration[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| --- | ||
| 'e2b': minor | ||
| '@e2b/python-sdk': minor | ||
| --- | ||
|
|
||
| Remove SDK-side defaults from API request payloads so the API defaults apply when options are omitted. Sandbox create/fork no longer preset a 5-minute timeout, fork no longer presets `count: 1`, create no longer presets `allow_internet_access` (sandboxes remain `secure` by default), pause no longer presets keeping memory, and template builds no longer preset CPU/memory. Explicitly provided values are still sent unchanged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,105 @@ | ||
| import { afterAll, afterEach, beforeAll, expect, test } from 'vitest' | ||
| import { http, HttpResponse } from 'msw' | ||
| import { setupServer } from 'msw/node' | ||
|
|
||
| import { Sandbox } from '../../src' | ||
| import { TEST_API_KEY, apiUrl } from '../setup' | ||
|
|
||
| let lastCreateBody: Record<string, unknown> | undefined | ||
| let lastForkBody: Record<string, unknown> | undefined | ||
| let lastPauseBody: Record<string, unknown> | undefined | ||
|
|
||
| const server = setupServer( | ||
| http.post(apiUrl('/sandboxes'), async ({ request }) => { | ||
| lastCreateBody = (await request.json()) as Record<string, unknown> | ||
| return HttpResponse.json({ | ||
| sandboxID: 'test-sandbox-id', | ||
| templateID: 'base', | ||
| envdVersion: '0.2.4', | ||
| }) | ||
| }), | ||
| http.post(apiUrl('/sandboxes/:sandboxID/fork'), async ({ request }) => { | ||
| lastForkBody = (await request.json()) as Record<string, unknown> | ||
| return HttpResponse.json([ | ||
| { | ||
| sandbox: { | ||
| sandboxID: 'forked-sandbox-id', | ||
| templateID: 'base', | ||
| envdVersion: '0.2.4', | ||
| }, | ||
| }, | ||
| ]) | ||
| }), | ||
| http.post(apiUrl('/sandboxes/:sandboxID/pause'), async ({ request }) => { | ||
| lastPauseBody = (await request.json()) as Record<string, unknown> | ||
| return new HttpResponse(null, { status: 204 }) | ||
| }) | ||
| ) | ||
|
|
||
| beforeAll(() => server.listen({ onUnhandledRequest: 'error' })) | ||
|
|
||
| afterAll(() => server.close()) | ||
|
|
||
| afterEach(() => { | ||
| lastCreateBody = undefined | ||
| lastForkBody = undefined | ||
| lastPauseBody = undefined | ||
| server.resetHandlers() | ||
| }) | ||
|
|
||
| test('Sandbox.create omits timeout and allow_internet_access when unset and defaults secure to true', async () => { | ||
| await Sandbox.create('base', { apiKey: TEST_API_KEY }) | ||
|
|
||
| expect(lastCreateBody).toBeDefined() | ||
| expect(lastCreateBody).not.toHaveProperty('timeout') | ||
| expect(lastCreateBody?.secure).toBe(true) | ||
| expect(lastCreateBody).not.toHaveProperty('allow_internet_access') | ||
| }) | ||
|
|
||
| test('Sandbox.create sends explicit timeout, secure and allow_internet_access', async () => { | ||
| await Sandbox.create('base', { | ||
| apiKey: TEST_API_KEY, | ||
| timeoutMs: 60_000, | ||
| secure: false, | ||
| allowInternetAccess: false, | ||
| }) | ||
|
|
||
| expect(lastCreateBody?.timeout).toBe(60) | ||
| expect(lastCreateBody?.secure).toBe(false) | ||
| expect(lastCreateBody?.allow_internet_access).toBe(false) | ||
| }) | ||
|
|
||
| test('Sandbox.fork omits timeout and count when unset', async () => { | ||
| await Sandbox.fork('test-sandbox-id', { apiKey: TEST_API_KEY }) | ||
|
|
||
| expect(lastForkBody).toBeDefined() | ||
| expect(lastForkBody).not.toHaveProperty('timeout') | ||
| expect(lastForkBody).not.toHaveProperty('count') | ||
| }) | ||
|
|
||
| test('Sandbox.fork sends explicit timeout and count', async () => { | ||
| await Sandbox.fork('test-sandbox-id', { | ||
| apiKey: TEST_API_KEY, | ||
| timeoutMs: 60_000, | ||
| count: 2, | ||
| }) | ||
|
|
||
| expect(lastForkBody?.timeout).toBe(60) | ||
| expect(lastForkBody?.count).toBe(2) | ||
| }) | ||
|
|
||
| test('Sandbox.pause omits memory when keepMemory is unset', async () => { | ||
| await Sandbox.pause('test-sandbox-id', { apiKey: TEST_API_KEY }) | ||
|
|
||
| expect(lastPauseBody).toBeDefined() | ||
| expect(lastPauseBody).not.toHaveProperty('memory') | ||
| }) | ||
|
|
||
| test('Sandbox.pause sends an explicit keepMemory', async () => { | ||
| await Sandbox.pause('test-sandbox-id', { | ||
| apiKey: TEST_API_KEY, | ||
| keepMemory: false, | ||
| }) | ||
|
|
||
| expect(lastPauseBody?.memory).toBe(false) | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.