-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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: connected account bugfix #1365
base: master
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
creation_date = datetime.fromisoformat( | ||
connected_account.createdAt.replace("Z", "+00:00") | ||
) | ||
if latest_account is None or creation_date > latest_creation_date: | ||
if latest_account is None or creation_date < latest_creation_date: |
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 logic for finding the latest account is incorrect - using <
will return the oldest account instead of newest. Should use >
to get most recent creation_date
.
📝 Committable Code Suggestion
‼️ Ensure you review the code suggestion before committing it to the branch. Make sure it replaces the highlighted code, contains no missing lines, and has no issues with indentation.
creation_date = datetime.fromisoformat( | |
connected_account.createdAt.replace("Z", "+00:00") | |
) | |
if latest_account is None or creation_date > latest_creation_date: | |
if latest_account is None or creation_date < latest_creation_date: | |
creation_date = datetime.fromisoformat( | |
connected_account.createdAt.replace("Z", "+00:00") | |
) | |
if latest_account is None or creation_date > latest_creation_date: |
@@ -342,7 +342,7 @@ def get_connection( | |||
creation_date = datetime.fromisoformat( | |||
connected_account.createdAt.replace("Z", "+00:00") | |||
) | |||
if latest_account is None or creation_date > latest_creation_date: | |||
if latest_account is None or creation_date < latest_creation_date: |
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 variable names latest_account
and latest_creation_date
are misleading since we're actually tracking the earliest account. Consider renaming these to earliest_account
and earliest_creation_date
to better reflect their purpose.
@@ -342,7 +342,7 @@ def get_connection( | |||
creation_date = datetime.fromisoformat( | |||
connected_account.createdAt.replace("Z", "+00:00") | |||
) | |||
if latest_account is None or creation_date > latest_creation_date: | |||
if latest_account is None or creation_date < latest_creation_date: |
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 a clarifying comment above this line to explain the logic:
# Find the earliest connected account based on creation date
This will help future developers understand the intention of this comparison.
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 d1bacc6 in 1 minute and 18 seconds
More details
- Looked at
13
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/composio/client/__init__.py:345
- Draft comment:
The operator is reversed. Using '<' selects the oldest account rather than the latest. For the latest account, use '>' instead. - Reason this comment was not posted:
Marked as duplicate.
Workflow ID: wflow_Ve2ZXpphvvQHmkpb
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.
@@ -342,7 +342,7 @@ def get_connection( | |||
creation_date = datetime.fromisoformat( | |||
connected_account.createdAt.replace("Z", "+00:00") | |||
) | |||
if latest_account is None or creation_date > latest_creation_date: | |||
if latest_account is None or creation_date < latest_creation_date: |
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 condition is reversed. Using '<' here will select the oldest account, not the latest. For the intended behavior, it should be 'creation_date > latest_creation_date'.
if latest_account is None or creation_date < latest_creation_date: | |
if latest_account is None or creation_date > latest_creation_date: |
Code Review SummaryChanges Overview
Code Quality Assessment
Recommendations
Overall, this is a valid bug fix that improves the reliability of account selection. The changes are safe to merge with the suggested improvements being optional enhancements for future consideration. |
Earlier the toolset picked the first connected account. Now, it picks the latest connected account
Important
Fixes logic in
get_connection
method to select the latest connected account by creation date.get_connection
method ofEntity
class in__init__.py
to select the latest connected account by creation date.>
to<
to ensure the latest account is selected.This description was created by
for d1bacc6. It will automatically update as commits are pushed.