Skip to content

Conversation

@ValentaTomas
Copy link
Member

@ValentaTomas ValentaTomas commented Oct 13, 2025

Note

Return NotFound errors on 404 for sandbox get info and set timeout in JS and Python SDKs.

  • SDKs:
    • JS (packages/js-sdk/src/sandbox/sandboxApi.ts):
      • setTimeout and getFullInfo now throw NotFoundError on HTTP 404.
    • Python:
      • Async (packages/python-sdk/e2b/sandbox_async/sandbox_api.py):
        • _cls_get_info raises NotFoundException on 404.
        • _cls_set_timeout raises NotFoundException on 404 (paused sandbox message).
      • Sync (packages/python-sdk/e2b/sandbox_sync/sandbox_api.py):
        • _cls_get_info raises NotFoundException on 404.
        • _cls_set_timeout raises NotFoundException on 404.

Written by Cursor Bugbot for commit 39504d9. This will update automatically on new commits. Configure here.

@changeset-bot
Copy link

changeset-bot bot commented Oct 13, 2025

🦋 Changeset detected

Latest commit: 39504d9

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@e2b/python-sdk Patch
e2b Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@mishushakov
Copy link
Member

Hey @ValentaTomas, any reason this is not in the handleApiError / handle_api_exception method?

)

if res.status_code == 404:
raise NotFoundException(f"Paused sandbox {sandbox_id} not found")
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Incorrect Error Message for Sandbox Timeout

The async _cls_set_timeout method's 404 error message incorrectly specifies "Paused sandbox {sandbox_id} not found". The set_timeout operation applies to any sandbox state, not just paused ones, making this message misleading and inconsistent with the sync version.

Additional Locations (1)

Fix in Cursor Fix in Web

@ValentaTomas
Copy link
Member Author

@mishushakov, I wasn't sure when looking at the new build endpoints that seem to sometimes return 404, but are using BuildError by default, if changing the error in the general error handler wouldn't break anything, + I wanted to have a nicer message there. We can generalize if it is 100% not a problem.

@mishushakov
Copy link
Member

mishushakov commented Oct 14, 2025

@ValentaTomas we aren't using BuildError by default. I have changed the implementation in the handler so it can use custom error class (SandboxError by default). I'd move any common error code here unless they're endpoint-specific.

export function handleApiError(
  response: FetchResponse<any, any, any>,
  errorClass: new (
    message: string,
    stackTrace?: string
  ) => Error = SandboxError,
  stackTrace?: string
)

@mishushakov
Copy link
Member

mishushakov commented Oct 14, 2025

you can throw all 404 as NotFoundException also, doesn't have to be Sandbox/Build error

@ValentaTomas
Copy link
Member Author

Probably ok then. We might want to refine the server errors then (https://github.com/e2b-dev/infra/blob/add-client-proxy-retries/packages/api/internal/handlers/sandbox_get.go#L97 for example) if we are then exposing them via the general 404 handler.

@ValentaTomas
Copy link
Member Author

ValentaTomas commented Oct 14, 2025

@ValentaTomas we aren't using BuildError by default. I have changed the implementation in the handler so it can use custom error class (SandboxError by default). I'd move any common error code here unless they're endpoint-specific.

I know, but for example here (not sure if this specifically can return 404, but I found 404 in the API build handlers) if I add the explicit 404 general handler, this will now stop returning BuildError, but can return NotFoundError.

@mishushakov
Copy link
Member

mishushakov commented Oct 15, 2025

@ValentaTomas Same behavior as we have the with the AuthenticationError - it's not specific to Sandbox or Build.

@ValentaTomas
Copy link
Member Author

@mishushakov I'm okay with that, but didn' want to break anything in the build system if you rely on this being BuildError anywhere.

@mishushakov
Copy link
Member

404 status would be unexpected in Build system

@ValentaTomas
Copy link
Member Author

404 status would be unexpected in Build system

Well, you can get that as the API can return that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants