-
Notifications
You must be signed in to change notification settings - Fork 2.6k
refactor: Remove exceptions from RooHandler constructor #7302
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- RooHandler constructor no longer throws RooAuthenticationError - Removed RooAuthenticationError class entirely - Authentication errors now handled by provider-proxy server (401 responses) - Removed pre-flight authentication check from ClineProvider.createTask - Updated webviewMessageHandler to handle generic errors instead of RooAuthenticationError - Client gracefully handles server error responses This change ensures provider constructors never throw exceptions, delegating all error handling to the server level for better separation of concerns.
cte
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for your contribution! I've reviewed the changes and have some suggestions for improvement. The refactor successfully removes exceptions from the constructor as intended, following the pattern established by other providers. The main concern is ensuring all mentioned changes are included and that error handling provides appropriate user feedback.
| providerName: "Roo Code Cloud", | ||
| baseURL: process.env.ROO_CODE_PROVIDER_URL ?? "https://api.roocode.com/proxy/v1", | ||
| apiKey: sessionToken, | ||
| apiKey: sessionToken || "unauthenticated", // Use a placeholder if no token |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using the string "unauthenticated" as a placeholder API key could be misleading. Consider using an empty string or a more descriptive placeholder like "NO_AUTH_TOKEN" to make the intent clearer:
| }) | ||
| } catch (error) { | ||
| // For all errors, reset the UI and show error | ||
| await provider.postMessageToWebview({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error handling here catches all errors generically but still sends a "newChat" message on error, which might not be the intended behavior. Also, the error message shown to the user doesn't distinguish between authentication errors and other types of errors. Consider:
- Should we really send "newChat" on error?
- Could we provide more specific error messages based on the error type?
| if (!sessionToken) { | ||
| throw new Error(t("common:errors.roo.authenticationRequired")) | ||
| if (CloudService.hasInstance()) { | ||
| sessionToken = CloudService.instance.authService?.getSessionToken() || "" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider adding debug logging when falling back to an empty token (without exposing the actual token value). This could help with debugging authentication issues.
The RooHandler constructor no longer throws exceptions when authentication is unavailable. Updated tests to expect the constructor to succeed gracefully in all cases, delegating authentication error handling to the server level.
Summary
This PR refactors the Roo provider to ensure that constructors never throw exceptions. Instead, authentication errors are now handled at the server level through HTTP status codes (e.g., 401 for unauthenticated requests).
Changes
ClineProvider.createTask()for the Roo provider has been removedRooAuthenticationErrorRationale
Based on feedback from PR #7298, provider constructors should never throw exceptions. This ensures:
Testing
Related
Important
Refactor
RooHandlerto avoid exceptions in constructor, handle authentication errors server-side, and update tests accordingly.RooHandlerconstructor no longer throws exceptions; uses empty token if session token unavailable.RooAuthenticationErrorclass.webviewMessageHandlerto use generic error handling.roo.spec.tsto ensureRooHandlerconstructor does not throw exceptions.This description was created by
for bbf9c13. You can customize this summary. It will automatically update as commits are pushed.