-
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: auth schemes #1226
base: master
Are you sure you want to change the base?
fix: auth schemes #1226
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
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.
👍 Looks good to me! Reviewed everything up to 7b1061b in 21 seconds
More details
- Looked at
132
lines of code in3
files - Skipped
0
files when reviewing. - Skipped posting
3
drafted comments based on config settings.
1. python/composio/cli/add.py:246
- Draft comment:
Ensureauth_mode
is checked forNone
before callinglower()
to avoid potentialAttributeError
. This is already done in the PR, but ensure consistency across the codebase. - Reason this comment was not posted:
Confidence changes required:50%
The PR introduces a change whereauth_mode
is checked forNone
before callinglower()
. This is a good practice to avoid potentialAttributeError
ifauth_mode
isNone
. However, the same check should be applied consistently across the codebase whereauth_mode
is used.
2. python/composio/client/collections.py:373
- Draft comment:
Ensureauth_scheme.mode
is a validAuthSchemeType
before casting to avoid potential runtime errors. - Reason this comment was not posted:
Confidence changes required:50%
The PR changes theAppAuthScheme
class to useOptional
for several fields, which is a good practice for fields that may not always have a value. However, themode
field is being cast toAuthSchemeType
without checking if it is a valid value. This could lead to runtime errors ifmode
is not a validAuthSchemeType
.
3. python/composio/tools/toolset.py:1062
- Draft comment:
Ensureauth_scheme
is checked forNone
before callingupper()
to avoid potentialAttributeError
. This is already done in the PR, but ensure consistency across the codebase. - Reason this comment was not posted:
Confidence changes required:50%
The PR introduces a change whereauth_mode
is checked forNone
before callingupper()
. This is a good practice to avoid potentialAttributeError
ifauth_mode
isNone
. However, the same check should be applied consistently across the codebase whereauth_mode
is used.
Workflow ID: wflow_P1g94F501tQcPIzY
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
apps: t.Union[AppModel, t.List[AppModel]] = super().get(queries=queries) | ||
for app in apps: | ||
if app.auth_schemes is not None: # type: ignore | ||
for auth_scheme in app.auth_schemes: # type: ignore | ||
if auth_scheme.mode is not None: | ||
auth_scheme.auth_mode = t.cast(AuthSchemeType, auth_scheme.mode) | ||
return apps |
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.
Type casting apps
to AppModel
before iteration can raise TypeError
since apps
could be a single AppModel
. Should check type and handle single model case.
📝 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.
apps: t.Union[AppModel, t.List[AppModel]] = super().get(queries=queries) | |
for app in apps: | |
if app.auth_schemes is not None: # type: ignore | |
for auth_scheme in app.auth_schemes: # type: ignore | |
if auth_scheme.mode is not None: | |
auth_scheme.auth_mode = t.cast(AuthSchemeType, auth_scheme.mode) | |
return apps | |
apps: t.Union[AppModel, t.List[AppModel]] = super().get(queries=queries) | |
if isinstance(apps, AppModel): | |
if apps.auth_schemes is not None: | |
for auth_scheme in apps.auth_schemes: | |
if auth_scheme.mode is not None: | |
auth_scheme.auth_mode = t.cast(AuthSchemeType, auth_scheme.mode) | |
else: | |
for app in apps: | |
if app.auth_schemes is not None: | |
for auth_scheme in app.auth_schemes: | |
if auth_scheme.mode is not None: | |
auth_scheme.auth_mode = t.cast(AuthSchemeType, auth_scheme.mode) | |
return apps |
python/composio/tools/toolset.py
Outdated
if scheme.auth_mode is not None: | ||
if auth_scheme != scheme.auth_mode.upper(): | ||
continue |
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.
Potential NoneType
error when accessing auth_mode
- need to check if scheme
itself is not None
before accessing auth_mode
📝 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.
if scheme.auth_mode is not None: | |
if auth_scheme != scheme.auth_mode.upper(): | |
continue | |
if scheme is not None and scheme.auth_mode is not None: | |
if auth_scheme != scheme.auth_mode.upper(): | |
continue |
@@ -293,8 +293,10 @@ class AuthSchemeField(BaseModel): | |||
class AppAuthScheme(BaseModel): | |||
"""App authenticatio scheme.""" |
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.
There's a typo in the docstring: authenticatio
should be authentication
@@ -1051,8 +1058,9 @@ def get_expected_params_for_user( | |||
# without user inputs to create an integratuib, if yes then create |
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.
There's a typo in the comment: integratuib
should be integration
scheme_name: t.Optional[str] = None | ||
name: t.Optional[str] = None | ||
auth_mode: t.Optional[AuthSchemeType] = None | ||
mode: t.Optional[str] = None |
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 docstring to explain the purpose of the mode
field and its relationship with auth_mode
. This would help clarify why both fields exist and when each should be used.
) -> t.List[AppModel]: | ||
apps = self.client.apps.get() | ||
# added type ignore since method overload was not being referenced |
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 type ignore comment should explain why the method overload is not being referenced and what's the proper way to fix it. This would help future maintainers understand if this is a temporary workaround or a permanent solution.
Code Review SummaryThe changes look good overall, with improvements to authentication scheme handling and type safety. Here's a breakdown: Positives:
Areas for Improvement:
The code changes are well-structured and improve the robustness of the authentication handling. The suggestions are mostly about documentation and clarity rather than functional issues. Rating: 8/10 - Solid improvements with minor documentation needs. |
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. Incremental review on 277eae9 in 36 seconds
More details
- Looked at
30
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
0
drafted comments based on config settings.
Workflow ID: wflow_Bt62BKfJgA36Xx0H
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.
@@ -67,6 +68,17 @@ def test_uninitialize_app() -> None: | |||
ComposioToolSet().get_action_schemas(actions=[Action.ATTIO_UPDATE_A_LIST]) | |||
|
|||
|
|||
def test_get_apps() -> None: |
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.
Handle the case where no app with no_auth
set to False
is found to avoid potential UnboundLocalError
.
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.
👍 Looks good to me! Incremental review on 8524a9e in 10 seconds
More details
- Looked at
12
lines of code in1
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/tests/test_tools/test_toolset.py:81
- Draft comment:
Unnecessary blank line. Consider removing it to maintain code consistency. - Reason this comment was not posted:
Confidence changes required:10%
The PR adds an unnecessary blank line which does not contribute to code readability or functionality.
Workflow ID: wflow_yOegUl0xHqvJDmk3
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
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.
👍 Looks good to me! Incremental review on ec3e8a4 in 35 seconds
More details
- Looked at
92
lines of code in2
files - Skipped
0
files when reviewing. - Skipped posting
1
drafted comments based on config settings.
1. python/composio/tools/toolset.py:870
- Draft comment:
Theinclude_local
parameter is removed from the method signature but is still used in the method logic. Consider either removing its usage from the method or re-adding it to the method signature. - Reason this comment was not posted:
Comment looked like it was already resolved.
Workflow ID: wflow_cNrm9lqTYT4Xz3LD
You can customize Ellipsis with 👍 / 👎 feedback, review rules, user-specific overrides, quiet
mode, and more.
fixes ENG-2491
Important
Fixes and enhances handling of authentication schemes in Composio SDK, ensuring proper validation and error handling for missing or invalid auth modes.
auth_mode
inadd_integration()
inadd.py
to ensure it is notNone
before processing.get()
incollections.py
to setauth_mode
frommode
if available.ComposioSDKError
inget_expected_params_for_user()
andfetch_expected_integration_params()
intoolset.py
ifauth_mode
isNone
.t.Optional
toscheme_name
,name
,auth_mode
, andmode
inAppAuthScheme
incollections.py
.test_get_apps()
intest_toolset.py
to verifyauth_mode
is inAUTH_SCHEMES
.auth_mode
intest_toolset.py
to ensure proper handling of auth schemes.This description was created by for ec3e8a4. It will automatically update as commits are pushed.