Skip to content

Conversation

@roomote
Copy link
Contributor

@roomote roomote bot commented Jan 7, 2026

Summary

This PR attempts to address Issue #10016. Feedback and guidance are welcome.

Problem

When API providers return HTTP status codes like 402 (Payment Required / insufficient balance), users see a generic "Unknown API error. Please contact Roo Code support." message instead of a user-friendly message like "You seem to have run out of funds/credits in your account."

The UI (ChatRow.tsx) already has localized messages for common HTTP status codes (400, 401, 402, 403, 429, 500) but they were not being shown because the error message format did not allow the UI to extract the status code.

Solution

Modified handleProviderError in src/api/providers/utils/error-handler.ts to prefix error messages with the HTTP status code when status >= 400.

Before: DeepSeek completion error: Insufficient balance
After: 402 - DeepSeek completion error: Insufficient balance

This allows the UI to:

  1. Parse the status code from the first 3 characters of the error message
  2. Look up the appropriate localized user-friendly message
  3. Display helpful guidance (e.g., "Go to your provider and add more to continue")

Changes

  • Modified handleProviderError to prefix error messages with HTTP status codes >= 400
  • Added comprehensive tests for HTTP 402, 401, 403, 429, and 500 error handling
  • Updated existing tests to account for the new message format

Testing

All existing and new tests pass:

  • 34 tests in error-handler.spec.ts
  • 16 tests in openai-error-handler.spec.ts
  • 22 tests in deepseek.spec.ts

Closes #10016


Important

Enhances handleProviderError to prefix error messages with HTTP status codes for improved UI error handling.

  • Behavior:
    • handleProviderError in error-handler.ts now prefixes error messages with HTTP status codes for errors with status >= 400.
    • UI can parse these codes to display localized messages.
  • Testing:
    • Added tests in error-handler.spec.ts for HTTP 402, 401, 403, 429, and 500 error handling.
    • Updated existing tests to verify new message format.
  • Misc:
    • handleOpenAIError remains an alias for handleProviderError with a default "completion" prefix.

This description was created by Ellipsis for e91bb85. You can customize this summary. It will automatically update as commits are pushed.

Fixes issue where providers like DeepSeek show "Unknown API error"
instead of user-friendly messages for HTTP status codes like 402
(insufficient balance/payment required).

Changes:
- Modify handleProviderError to prefix error messages with HTTP status
  code (e.g., "402 - DeepSeek completion error: ...") when status >= 400
- This allows the UI (ChatRow.tsx) to parse the status code and display
  appropriate user-friendly messages from the localization files
- Preserves existing behavior for custom messageTransformers and
  non-HTTP errors

The UI already has localized messages for common HTTP status codes
(400, 401, 402, 403, 429, 500) but they were not being shown because
the error message format did not allow the UI to extract the status code.

Closes #10016
@roomote
Copy link
Contributor Author

roomote bot commented Jan 7, 2026

Rooviewer Clock   See task on Roo Cloud

Reviewed the changes to handleProviderError in error-handler.ts. The implementation correctly prefixes error messages with HTTP status codes (>= 400) enabling the UI to parse and display user-friendly localized messages.

No issues found. The code is well-tested with comprehensive coverage of all status codes and edge cases.

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 Jan 7, 2026
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] Deepseek shows "Unknown API error. Please contact Roo Code support." instead out of balance

3 participants