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: Only fetch actions available to an entity during schema validation #1095

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions python/composio/tools/toolset.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def add_auth(
parameters=parameters,
)

def check_connected_account(self, action: ActionType) -> None:
def check_connected_account(self, action: ActionType, entity_id: str) -> None:
"""Check if connected account is required and if required it exists or not."""
action = Action(action)
if action.no_auth or action.is_runtime:
Expand All @@ -435,6 +435,7 @@ def check_connected_account(self, action: ActionType) -> None:
# Normalize app names/ids coming from API
connection.appUniqueId.upper()
for connection in self._connected_accounts
if connection.entityId == entity_id
]:
raise ComposioSDKError(
f"No connected account found for app `{action.app}`; "
Expand Down Expand Up @@ -487,7 +488,7 @@ def _execute_remote(
"""Execute a remote action."""
auth = self._custom_auth.get(App(action.app))
if auth is None:
self.check_connected_account(action=action)
self.check_connected_account(action=action, entity_id=entity_id)

entity = self.client.get_entity(id=entity_id)
output = entity._execute( # pylint: disable=protected-access
Expand Down Expand Up @@ -898,7 +899,7 @@ def get_action_schemas(
)
if check_connected_accounts:
for item in remote_items:
self.check_connected_account(action=item.name)
self.check_connected_account(action=item.name, entity_id=self.entity_id)
else:
warnings.warn(
"Not verifying connected accounts for apps."
Expand Down
Loading