-
Notifications
You must be signed in to change notification settings - Fork 97
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
fix: add check for backend connectivity while validating credentials #1443
Conversation
Warning Rate limit exceeded@AdiGajbhiye has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 3 seconds before requesting another review. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. WalkthroughThe changes involve updates to the Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant ValidationProvider
participant AltimateAPI
User->>ValidationProvider: Request to validate credentials
ValidationProvider->>AltimateAPI: checkApiConnectivity()
AltimateAPI-->>ValidationProvider: Return status
alt if status is "ok"
ValidationProvider-->>User: Proceed with validation
else
ValidationProvider-->>User: Display error message
end
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
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.
❌ Changes requested. Reviewed everything up to 57b5931 in 20 seconds
More details
- Looked at
18
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. src/validation_provider/index.ts:72
- Draft comment:
Please specify a return type for the_validateCredentials
function to improve code clarity and maintainability. This applies to other utility functions as well. - Reason this comment was not posted:
Comment was on unchanged code.
Workflow ID: wflow_J4dS3qQa52SPksbC
Want Ellipsis to fix these issues? Tag @ellipsis-dev
in a comment. You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
if (!silent) { | ||
window.showErrorMessage("Unable to connect to altimate backend."); | ||
} | ||
return; |
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 setting this._isAuthenticated = false;
here to ensure the authentication state is correctly updated when connectivity fails.
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.
src/validation_provider/index.ts
Outdated
const connectivity = await this.altimate.checkApiConnectivity(); | ||
if (connectivity?.status !== "ok") { | ||
if (!silent) { | ||
window.showErrorMessage("Unable to connect to altimate backend."); | ||
} | ||
return; | ||
} |
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.
Set _isAuthenticated
to false
when connectivity check fails
When the connectivity check fails, the _isAuthenticated
flag is not updated. To maintain consistent authentication state and prevent potential issues due to stale authentication status, consider setting this._isAuthenticated = false
when the connectivity check fails.
Apply this diff to fix the issue:
const connectivity = await this.altimate.checkApiConnectivity();
if (connectivity?.status !== "ok") {
if (!silent) {
window.showErrorMessage("Unable to connect to altimate backend.");
}
+ this._isAuthenticated = false;
return;
}
📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
const connectivity = await this.altimate.checkApiConnectivity(); | |
if (connectivity?.status !== "ok") { | |
if (!silent) { | |
window.showErrorMessage("Unable to connect to altimate backend."); | |
} | |
return; | |
} | |
const connectivity = await this.altimate.checkApiConnectivity(); | |
if (connectivity?.status !== "ok") { | |
if (!silent) { | |
window.showErrorMessage("Unable to connect to altimate backend."); | |
} | |
this._isAuthenticated = false; | |
return; | |
} |
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.
👍 Looks good to me! Incremental review on 11d96a6 in 7 seconds
More details
- Looked at
12
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. src/validation_provider/index.ts:79
- Draft comment:
Consider using a constant or a localization mechanism for the error message "Unable to connect to altimate backend." to facilitate easier updates and localization. - Reason this comment was not posted:
Confidence changes required:50%
The PR adds a connectivity check before validating credentials, which is a good addition. However, the error message for connectivity issues is hardcoded, which might not be ideal for localization or future changes.
Workflow ID: wflow_oa7iGwVaTLycCPVF
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
Overview
Problem
Currently if user is behind a firewall and unable to connect to altimate backend, he gets error message of "invalidate credentials".
Solution
Describe the implemented solution. Add external references if needed.
Screenshot/Demo
A picture is worth a thousand words. Please highlight the changes if applicable.
How to test
Checklist
README.md
updated and added information about my changeImportant
Adds backend connectivity check in
_validateCredentials()
inindex.ts
to prevent validation when backend is unreachable._validateCredentials()
inindex.ts
before validating credentials._validateCredentials()
to includecheckApiConnectivity()
call and handle its response.This description was created by for 11d96a6. It will automatically update as commits are pushed.