Skip to content
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: filter connections by entity [ENG-2523] #1200

Merged
merged 2 commits into from
Jan 20, 2025

Conversation

kaavee315
Copy link
Contributor

@kaavee315 kaavee315 commented Jan 15, 2025

Important

Modify get_connected_accounts() in toolset.py to filter connected accounts by entity_id if set.

  • Behavior:
    • Modify get_connected_accounts() in toolset.py to filter connected accounts by entity_id if entity_id is set.

This description was created by Ellipsis for 8583f3a. It will automatically update as commits are pushed.

Copy link

vercel bot commented Jan 15, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
composio ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 15, 2025 3:24pm

@kaavee315 kaavee315 changed the title Fix: filter connections by entity Fix: filter connections by entity [ENG-2523] Jan 15, 2025
Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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! Reviewed everything up to 6579900 in 14 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. python/composio/tools/toolset.py:1363
  • Draft comment:
    Ensure that the entity_id is correctly set and used throughout the class to avoid unexpected behavior when filtering connected accounts. This change assumes that self.entity_id is always correctly initialized and available.
  • Reason this comment was not posted:
    Confidence changes required: 50%
    The change in the PR modifies the get_connected_accounts method to filter connections by entity_id. This is a logical change to ensure that only connections related to the specific entity are retrieved. However, the change should be verified for potential issues.

Workflow ID: wflow_mc8ATjPfKYBrs8vm


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

Comment on lines 1362 to 1363
def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
return self.client.connected_accounts.get()
return self.client.connected_accounts.get(entity_ids=[self.entity_id] if self.entity_id else None)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing None for entity_ids parameter may behave differently than omitting it entirely. Consider skipping the parameter when entity_id is None rather than passing None explicitly. Additionally, the change introduces a potential issue where 'entity_ids' could be set to None, which might not be handled by the 'get' method, leading to unexpected behavior.

📝 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.

Suggested change
def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
return self.client.connected_accounts.get()
return self.client.connected_accounts.get(entity_ids=[self.entity_id] if self.entity_id else None)
def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
return self.client.connected_accounts.get(entity_ids=[self.entity_id] if self.entity_id else [])

@@ -1360,7 +1360,7 @@ def get_connected_account(self, id: str) -> ConnectedAccountModel:
return self.client.connected_accounts.get(connection_id=id)

def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding docstring to clarify the behavior of entity filtering:

def get_connected_accounts(self) -> t.List[ConnectedAccountModel]:
    """
    Retrieve connected accounts filtered by the current entity ID.
    
    Returns:
        List[ConnectedAccountModel]: List of connected accounts for the current entity.
                                   If no entity_id is set, returns all accounts.
    """

@shreysingla11
Copy link
Collaborator

Code Review Summary

The changes look good and fix an important issue with entity-based filtering of connected accounts. Here's my assessment:

Strengths:

✅ Properly implements entity-based filtering
✅ Handles the None case correctly
✅ Maintains type safety
✅ Follows existing patterns in the codebase

Suggestions:

  • Consider adding docstring to document the filtering behavior
  • Could benefit from unit tests to verify filtering behavior

Overall code quality: 8/10 - Clean fix that improves data isolation between entities.

@kaavee315 kaavee315 changed the title Fix: filter connections by entity [ENG-2523] fix: filter connections by entity [ENG-2523] Jan 15, 2025
Comment on lines +1363 to +1365
return self.client.connected_accounts.get(
entity_ids=[self.entity_id] if self.entity_id else None
)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The refactored code introduces a potential issue with readability due to inconsistent indentation, which may lead to confusion during maintenance.

Copy link
Contributor

@ellipsis-dev ellipsis-dev bot left a 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 8583f3a in 11 seconds

More details
  • Looked at 15 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 1 drafted comments based on config settings.
1. python/composio/tools/toolset.py:1363
  • Draft comment:
    Reformatting for readability is good, but ensure that the logic remains unchanged. This change is non-functional and only affects code style.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The change in the PR is a simple reformatting of the code for better readability. It doesn't introduce any functional changes or bugs.

Workflow ID: wflow_UThCqvsQxEBVDSQY


You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet mode, and more.

@angrybayblade angrybayblade merged commit f8218b3 into master Jan 20, 2025
22 of 23 checks passed
@angrybayblade angrybayblade deleted the kaavee/fix_connections_filter branch January 20, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants