fix: attach HTTP status codes to Cerebras API errors for proper UI display #10231
+95
−14
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.
Related GitHub Issue
Closes: #10212
Description
This PR attempts to address the issue where Cerebras API errors were displaying "Unknown API error. Please contact Roo Code support." instead of the actual error messages.
Root Cause:
The Cerebras provider was throwing
Errorobjects without attaching the HTTPstatusproperty. The frontend (ChatRow.tsx) relies on this status property to display appropriate error messages based on HTTP status codes (401, 403, 429, 500, etc.). Without the status, the UI defaults to showing "Unknown API error."Solution:
throwWithStatushelper function that creates Error objects with the HTTP status code attachedcreateMessageandcompletePromptmethods to usethrowWithStatusTest Procedure
Unit tests added and passing:
should attach HTTP status code to error objects(401 error)should attach HTTP status code for rate limit errors(429 error)should attach HTTP status code for server errors(500 error)To manually test:
Run tests:
cd src && npx vitest run api/providers/__tests__/cerebras.spec.tsPre-Submission Checklist
Documentation Updates
Additional Notes
Feedback and guidance are welcome. This is an attempt to address the issue based on analysis of the error handling flow from the Cerebras provider through to the UI.