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

feat: pick active connection only #1152

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

himanshu-dixit
Copy link
Collaborator

@himanshu-dixit himanshu-dixit commented Jan 3, 2025

🔍 Review Summary

The update involves a minor enhancement in base.toolset.ts by adding a filter for active connections, ensuring minimal impact on the overall codebase.

Original Description

None


Important

Enhance ComposioToolSet.executeAction to filter and use only active connected accounts.

  • Behavior:
    • In ComposioToolSet.executeAction, filters connected accounts by status: "ACTIVE" and showActiveOnly: true to ensure only active accounts are considered.
  • Misc:
    • No other files or functions are affected by this change.

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

Copy link

vercel bot commented Jan 3, 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 3, 2025 11:29am

Copy link

Walkthrough

The PR introduces a minor change by adding two lines to filter active connections in base.toolset.ts. This does not significantly impact the codebase.

🔗 Related PRs

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @bot + *your message*
Example: @bot Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @bot + *feedback*
Example: @bot Do not comment on `save_auth` function !

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.

❌ Changes requested. Reviewed everything up to 9c07c50 in 50 seconds

More details
  • Looked at 13 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 0 drafted comments based on config settings.

Workflow ID: wflow_ype1LxFe5WAzp85D


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.

@@ -236,6 +236,8 @@ export class ComposioToolSet {
// fetch connected account id
const connectedAccounts = await this.client.connectedAccounts.list({
user_uuid: entityId,
status: "ACTIVE",
Copy link
Contributor

Choose a reason for hiding this comment

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

The status: "ACTIVE" parameter is redundant when showActiveOnly: true is used. Consider removing status: "ACTIVE".

Copy link

github-actions bot commented Jan 3, 2025

This comment was generated by github-actions[bot]!

JS SDK Coverage Report

📊 Coverage report for JS SDK can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/coverage-12597009954/coverage/index.html

📁 Test report folder can be found at the following URL:
https://pub-92e668239ab84bfd80ee07d61e9d2f40.r2.dev/html-report-12597009954/html-report/report.html

@@ -236,6 +236,8 @@ export class ComposioToolSet {
// fetch connected account id
const connectedAccounts = await this.client.connectedAccounts.list({
user_uuid: entityId,
status: "ACTIVE",
showActiveOnly: true,
Copy link
Collaborator

Choose a reason for hiding this comment

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

There appears to be redundancy in the parameters. Both status: "ACTIVE" and showActiveOnly: true seem to serve the same purpose. Consider using just one of these parameters to maintain cleaner code. Additionally, the string literal "ACTIVE" should be defined as a constant for better maintainability.

@@ -236,6 +236,8 @@ export class ComposioToolSet {
// fetch connected account id
const connectedAccounts = await this.client.connectedAccounts.list({
user_uuid: entityId,
status: "ACTIVE",
showActiveOnly: true,
});
accountId = connectedAccounts?.items[0]?.id;
Copy link
Collaborator

Choose a reason for hiding this comment

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

The code assumes there will be active accounts by directly accessing items[0]. Consider adding explicit error handling for cases where no active accounts are found. For example:

if (!connectedAccounts?.items?.length) {
  throw CEG.getCustomError(
    COMPOSIO_SDK_ERROR_CODES.SDK.NO_ACTIVE_ACCOUNT_FOUND,
    {
      message: "No active connected account found for the user",
      description: "Please ensure user has at least one active connected account",
    }
  );
}

@shreysingla11
Copy link
Collaborator

Code Review Summary

The changes introduce filtering for active accounts, which is a good addition, but there are a few areas that could be improved:

  1. Parameter Redundancy: The PR adds both status: "ACTIVE" and showActiveOnly: true which appear to serve the same purpose. Consider using just one parameter.

  2. Error Handling: The code could benefit from explicit error handling when no active accounts are found.

  3. Code Quality Improvements:

    • Define "ACTIVE" as a constant
    • Add error handling for no active accounts case
    • Add documentation explaining the active account filtering

Suggested implementation:

const ACCOUNT_STATUS = {
  ACTIVE: 'ACTIVE'
} as const;

// Fetch connected account id, prioritizing active accounts
const connectedAccounts = await this.client.connectedAccounts.list({
  user_uuid: entityId,
  status: ACCOUNT_STATUS.ACTIVE,
});

if (!connectedAccounts?.items?.length) {
  throw CEG.getCustomError(
    COMPOSIO_SDK_ERROR_CODES.SDK.NO_ACTIVE_ACCOUNT_FOUND,
    {
      message: "No active connected account found for the user",
      description: "Please ensure user has at least one active connected account",
    }
  );
}

Overall, while the changes are moving in the right direction, addressing these points would make the code more robust and maintainable.

@himanshu-dixit himanshu-dixit merged commit b8532ee into master Jan 3, 2025
16 checks passed
@himanshu-dixit himanshu-dixit deleted the ft-pick-active-connection-only branch January 3, 2025 11:39
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