fix(handlers): return computed error status/message instead of generic 500#1708
Open
ankit25bcs10610 wants to merge 1 commit into
Open
fix(handlers): return computed error status/message instead of generic 500#1708ankit25bcs10610 wants to merge 1 commit into
ankit25bcs10610 wants to merge 1 commit into
Conversation
…c 500 completionsHandler, embeddingsHandler, imageGenerationsHandler and imageEditsHandler each compute `statusCode`/`errorMessage` in their catch block (setting 400 + the real message for a RouterError), but then returned a hardcoded `status: 500` and `message: 'Something went wrong'`, discarding both. As a result, conditional-routing failures that should surface as a 400 with the actual reason were returned as an opaque 500. The sibling handlers (chatCompletions, messages, messagesCountTokens, proxy) already use `message: errorMessage` / `status: statusCode`; align these four with that behavior. Co-Authored-By: Claude Opus 4.8 (1M context) <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.
What
Four handlers —
completionsHandler,embeddingsHandler,imageGenerationsHandler,imageEditsHandler— compute the correct error status and message in theircatchblock, then throw it away:So a conditional-routing failure (
RouterError) that should return 400 + the real reason instead returns an opaque 500 "Something went wrong", making these failures hard to diagnose for callers.Fix
Use the already-computed
errorMessageandstatusCodein the response. This matches the sibling handlers that already do the right thing:chatCompletionsHandler,messagesHandler,messagesCountTokensHandler,proxyHandler.8-line change across the four files; no behavior change for non-
RouterErrorerrors (still 500 + "Something went wrong").npm run format:checkpasses.