-
Notifications
You must be signed in to change notification settings - Fork 0
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 Creds for connection call #93
Conversation
Warning Rate Limit Exceeded@ruuushhh has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 6 minutes and 59 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. WalkthroughThe change primarily focuses on updating the method of retrieving Changes
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 as PR comments)
Additionally, you can add CodeRabbit Configration 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.
business_central_credentials: BusinessCentralCredentials = BusinessCentralCredentials.objects.get( | ||
workspace_id=workspace_id, is_expired=False, refresh_token__isnull=False | ||
) |
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 change to use objects.get
with additional filtering criteria (workspace_id=workspace_id, is_expired=False, refresh_token__isnull=False
) for retrieving BusinessCentralCredentials
is a significant improvement in terms of security and reliability. This ensures that only valid, non-expired credentials with a refresh token are used for establishing connections. However, consider handling the case where multiple credentials match the criteria, as objects.get
will raise a MultipleObjectsReturned
exception if more than one item matches the query. This scenario might occur if there are data inconsistencies or errors in how credentials are managed. Adding explicit handling for this exception or ensuring data integrity to prevent such cases is recommended.
The retrieval of BusinessCentralCredentials
using objects.get
is correctly implemented with the necessary filtering criteria. However, ensure that the system is designed to handle or prevent multiple credentials matching the criteria to avoid MultipleObjectsReturned
exceptions.
The exception handling for WrongParamsError
and InvalidTokenError
assumes that business_central_credentials
is always available, which might not be the case if the exception is raised before its assignment. Consider restructuring the code to ensure that the invalidation logic is only executed when business_central_credentials
is defined.
except (WrongParamsError, InvalidTokenError):
- if business_central_credentials:
+ try:
business_central_credentials.refresh_token = None
business_central_credentials.is_expired = True
business_central_credentials.save()
+ except NameError:
+ pass
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.
business_central_credentials: BusinessCentralCredentials = BusinessCentralCredentials.objects.get( | |
workspace_id=workspace_id, is_expired=False, refresh_token__isnull=False | |
) |
|
|
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## master #93 +/- ##
=======================================
Coverage 80.13% 80.13%
=======================================
Files 67 67
Lines 3337 3337
=======================================
Hits 2674 2674
Misses 663 663 ☔ View full report in Codecov by Sentry. |
|
business_central_credentials: BusinessCentralCredentials = BusinessCentralCredentials.objects.get( | ||
workspace_id=workspace_id, is_expired=False, refresh_token__isnull=False | ||
) |
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.
isn't these condition same as get_active_business_central_credentials
?
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.
No I updated it to filter
Summary by CodeRabbit
BusinessCentralCredentials
to enhance reliability and efficiency.