feat: add GatewayError for Blaxel gateway-synthesized errors#296
Open
devin-ai-integration[bot] wants to merge 2 commits into
Open
feat: add GatewayError for Blaxel gateway-synthesized errors#296devin-ai-integration[bot] wants to merge 2 commits into
devin-ai-integration[bot] wants to merge 2 commits into
Conversation
- Add GatewayError class with errorCode, statusCode, retryable, action, doNot, docsUrl fields - Add errorCodes.ts with all 10 stable gateway error code constants - Add gatewayErrorInterceptor response interceptor that throws GatewayError on X-Blaxel-Source: platform responses - Register interceptor before authenticationErrorInterceptor so gateway errors are caught first - Update SandboxAction.handleResponseError() to detect gateway errors and throw GatewayError instead of ResponseError - Export GatewayError and all error code constants from @blaxel/core Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
Skip 2xx responses so successful calls through the gateway are not incorrectly thrown as GatewayError. Co-Authored-By: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
LGTM
The P0 bug from the previous review — interceptor throwing on 2xx gateway responses — is fixed in b663f9e with the if (response.ok) return response; guard. The implementation is correct: the interceptor clones the response before reading the body, ordering is intentional, and the handleResponseError duplication correctly covers the direct-fetch path.
Tag @mendral-app with feedback or questions. View session
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
Adds structured gateway error support to the TypeScript SDK. When the Blaxel gateway proxy synthesizes an error response (identified by the
X-Blaxel-Source: platformheader), the SDK now throws aGatewayErrorwith typed properties:GatewayErrorclass extendingErrorwitherrorCode,statusCode,retryable,action,doNot?,docsUrl?, andresponsepropertieserrorCodes.ts(ERR_ROUTE_NOT_FOUND,ERR_WORKLOAD_UNAVAILABLE, etc.)gatewayErrorInterceptorresponse interceptor that detectsX-Blaxel-Source: platformand throwsGatewayErrorwith parsed body fields — registered before the auth interceptor so gateway errors are caught firstSandboxAction.handleResponseError()updated to check for gateway headers and throwGatewayErrorinstead ofResponseErrorwhen appropriate@blaxel/coreChanges:
@blaxel/core/src/client/gatewayError.ts— newGatewayErrorclass@blaxel/core/src/client/errorCodes.ts— new file with 10 error code constants@blaxel/core/src/client/responseInterceptor.ts— newgatewayErrorInterceptor+ registered inresponseInterceptorsarray@blaxel/core/src/sandbox/action.ts— gateway error detection inhandleResponseError()@blaxel/core/src/index.ts— re-export new symbolsReview & Testing Checklist for Human
gatewayErrorInterceptorcorrectly clones the response before reading the body, so downstream interceptors still have access to the originalGatewayErroris thrown with correcterrorCodeandretryablevaluesNotes
gatewayErrorInterceptoris registered inresponseInterceptors[]beforeauthenticationErrorInterceptor, so gateway-synthesized 401/403 errors will throwGatewayError(with the stable error code) instead of getting the auth doc link treatment — this is intentional since gateway errors have richer structured metadataSandboxAction.handleResponseError()also checks for gateway headers directly since sandbox subsystems may bypass the interceptor chain in some code paths (e.g. directh2Fetchcalls)Link to Devin session: https://app.devin.ai/sessions/90f8d135f6e64ae8b771918c3ceeec6a
Requested by: @Joffref
Note
Adds a
GatewayErrorclass and supporting infrastructure to surface structured errors from the Blaxel gateway proxy. When a response carriesX-Blaxel-Source: platform, the SDK now throwsGatewayErrorwith typed fields (errorCode,retryable,action, etc.) instead of a generic error. A new interceptor handles the common HTTP path;SandboxAction.handleResponseError()handles the direct-fetch path.Written by Mendral for commit b663f9e.