Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Dec 20, 2025

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 Error objects without attaching the HTTP status property. 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:

  • Added a throwWithStatus helper function that creates Error objects with the HTTP status code attached
  • Updated all error throwing locations in createMessage and completePrompt methods to use throwWithStatus
  • Modified outer catch blocks to preserve the status property when re-wrapping errors

Test Procedure

  1. 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)
  2. To manually test:

    • Configure Cerebras API with an invalid or expired API key
    • Attempt to use Roo Code with the Cerebras provider
    • Verify the error message shows the appropriate authentication error instead of "Unknown API error"
  3. Run tests: cd src && npx vitest run api/providers/__tests__/cerebras.spec.ts

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Documentation Impact: I have considered if my changes require documentation updates (see "Documentation Updates" section below).
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Documentation Updates

  • No documentation updates are required.

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.

…splay

Resolves issue where Cerebras API errors showed "Unknown API error" instead
of the actual error message.

The Cerebras provider was throwing Error objects without attaching the HTTP
status code, which is required by ChatRow to display appropriate error
messages. The frontend parses the status code from error objects to show
user-friendly messages based on HTTP status (401, 429, 500, etc.).

Changes:
- Add throwWithStatus helper to create errors with status property attached
- Update all error throwing locations to use throwWithStatus
- Preserve status when re-wrapping errors in outer catch blocks
- Add tests to verify status is attached to errors

Fixes #10212
@roomote
Copy link
Contributor Author

roomote bot commented Dec 20, 2025

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The implementation correctly:

  • Adds a throwWithStatus helper to create errors with HTTP status attached
  • Uses this helper for all HTTP error cases (401, 403, 429, 500+, and generic errors)
  • Preserves the status property when re-wrapping errors in outer catch blocks
  • Includes tests to verify the behavior

The approach is consistent with existing error handling patterns in the codebase (see handleProviderError in src/api/providers/utils/error-handler.ts).

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Dec 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels.

Projects

Status: Triage

Development

Successfully merging this pull request may close these issues.

[BUG] Cerebras API is not accessible.

3 participants