fix: use RateLimitException/RateLimitError consistently for 429 responses#1188
Open
MaxwellCalkin wants to merge 1 commit intoe2b-dev:mainfrom
Open
fix: use RateLimitException/RateLimitError consistently for 429 responses#1188MaxwellCalkin wants to merge 1 commit intoe2b-dev:mainfrom
MaxwellCalkin wants to merge 1 commit intoe2b-dev:mainfrom
Conversation
…nses Both Python and JS SDKs had inconsistent error handling for rate limit (429) responses in the envd API layer — returning generic SandboxException/SandboxError instead of RateLimitException/RateLimitError. This made it impossible for users to programmatically catch and handle rate limiting separately from other errors. Changes: - Python SDK envd/api.py: return RateLimitException instead of SandboxException for 429 status codes - Python SDK __init__.py: export RateLimitException so users can import it via `from e2b import RateLimitException` (parity with JS SDK which already exports RateLimitError) - JS SDK envd/api.ts: return RateLimitError instead of SandboxError for 429 status codes - JS SDK envd/rpc.ts: add ResourceExhausted gRPC code handler returning RateLimitError (parity with Python SDK rpc.py which already handles it) AI Disclosure: This PR was authored by Claude, an AI assistant by Anthropic (claude.ai/claude-code), operating transparently and not impersonating a human. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
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
Both Python and JS SDKs have inconsistent error handling for rate limit (HTTP 429) responses in the envd API layer. The envd API handlers return generic
SandboxException/SandboxErrorinstead of the dedicatedRateLimitException/RateLimitErrorclasses, making it impossible for users to programmatically catch and handle rate limiting separately from other errors.Additionally,
RateLimitExceptionis not exported from the Python SDK's top-level__init__.py, unlike the JS SDK which correctly exportsRateLimitError. This forces Python users to use the internal import pathfrom e2b.exceptions import RateLimitExceptioninstead of the standardfrom e2b import RateLimitException.Changes
Python SDK:
envd/api.py: ReturnRateLimitExceptioninstead ofSandboxExceptionfor 429 status codes (consistent withapi/__init__.pyandenvd/rpc.pywhich already useRateLimitException)__init__.py: ExportRateLimitExceptionin both the import and__all__(parity with JS SDK which exportsRateLimitError)JS SDK:
envd/api.ts: ReturnRateLimitErrorinstead ofSandboxErrorfor 429 status codes (consistent withapi/index.tswhich already usesRateLimitError)envd/rpc.ts: AddCode.ResourceExhaustedhandler returningRateLimitError(parity with Python SDK'srpc.pywhich already handles this gRPC code)Before/After
AI Disclosure
This PR was authored by Claude, an AI assistant by Anthropic (claude.ai/claude-code), operating transparently and not impersonating a human.