fix: handle invalid status codes gracefully in error handler#1167
Merged
Conversation
🦋 Changeset detectedLatest commit: a43504f The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
Package ArtifactsBuilt from 7749c45. Download artifacts from this workflow run. JS SDK ( npm install ./e2b-2.13.1-dobrac-status-code-0-error.0.tgzCLI ( npm install ./e2b-cli-2.7.3-dobrac-status-code-0-error.0.tgzPython SDK ( pip install ./e2b-2.14.0+dobrac.status.code.0.error-py3-none-any.whl |
Prevent crashes when API errors lack a proper HTTP status code (e.g., network failures, empty responses). Instead of throwing on status code 0, we now fall back to 'unknown error' while preserving the actual API error message. Uses status.message map lookup instead of calling the status() function. Includes tests covering invalid codes, missing codes, and known status codes.
3bc1331 to
a43504f
Compare
matthewlouisbrockman
approved these changes
Feb 26, 2026
Contributor
matthewlouisbrockman
left a comment
There was a problem hiding this comment.
looks good.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Prevents the CLI from crashing when the API returns an error without a standard HTTP status code (e.g., network failures, timeouts, empty responses). Instead of throwing on status code 0, we now fall back to 'unknown error' while preserving the actual API error message.
Changes
status.message[code]map lookup instead of callingstatus(code)which throws on invalid codesNote
Low Risk
Low risk: small change to error-message derivation plus unit tests; behavior only changes for unknown/invalid status codes (e.g., 0) to avoid throwing inside the handler.
Overview
Prevents the CLI error handler from crashing when the API returns a missing/invalid HTTP status code by replacing
statuses(code)with a safe lookup viastatus.message[code]and falling back tounknown error.Adds
vitestcoverage for no-error responses, known codes, code0/missing codes, and a non-hardcoded valid code (e.g.,502), and includes a patch changeset for@e2b/cli.Written by Cursor Bugbot for commit a43504f. This will update automatically on new commits. Configure here.