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: c6c09f5

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?

@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.

@ValentaTomas ValentaTomas requested review from dobrac and removed request for jakubno October 30, 2025 23:08
@ValentaTomas
Copy link
Member Author

@mishushakov Ready for final check.

@ValentaTomas ValentaTomas changed the title Return NotFoundError/Exception for get info and set timeout, instead of a generic error Return NotFoundError/Exception for errors with code 404 from API Oct 31, 2025
@ValentaTomas ValentaTomas changed the title Return NotFoundError/Exception for errors with code 404 from API Return NotFoundError/Exception for API errors with code 404 Oct 31, 2025
@ValentaTomas ValentaTomas force-pushed the improve-get-info-error branch from e718831 to 1287fbb Compare October 31, 2025 20:11
@ValentaTomas ValentaTomas force-pushed the improve-get-info-error branch from 1287fbb to 39504d9 Compare October 31, 2025 20:12
@ValentaTomas ValentaTomas changed the title Return NotFoundError/Exception for API errors with code 404 Return NotFoundError/Exception for "set timeout" and "get info" 404 errors Oct 31, 2025
@ValentaTomas ValentaTomas enabled auto-merge (squash) October 31, 2025 20:16
@ValentaTomas ValentaTomas merged commit 17d6e63 into main Oct 31, 2025
6 of 7 checks passed
@ValentaTomas ValentaTomas deleted the improve-get-info-error branch October 31, 2025 20:25
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