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: fetch default auth scheme from API during initiate_connection #895

Merged
merged 3 commits into from
Nov 23, 2024

Conversation

tushar-composio
Copy link
Collaborator

@tushar-composio tushar-composio commented Nov 23, 2024

Important

initiate_connection now fetches default auth scheme from API if not provided, with improved error message formatting in toolset.py.

  • Behavior:
    • initiate_connection in toolset.py now fetches default auth_scheme from API if not provided.
    • Default value of auth_scheme changed from "OAUTH2" to None.
  • Error Handling:
    • Improved error message formatting in fetch_expected_integration_params in toolset.py.

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

Copy link

vercel bot commented Nov 23, 2024

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 Nov 23, 2024 8:08am

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 94ee762 in 18 seconds

More details
  • Looked at 47 lines of code in 1 files
  • Skipped 0 files when reviewing.
  • Skipped posting 3 drafted comments based on config settings.
1. python/composio/tools/toolset.py:1356
  • Draft comment:
    Improved error message formatting for better readability and consistency.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The error message in the fetch_expected_integration_params function was updated to use app.name!r and auth_scheme!r for better readability and consistency. This is a good change as it improves the clarity of the error message.
2. python/composio/tools/toolset.py:1387
  • Draft comment:
    Changed auth_scheme default to None to allow dynamic fetching of default auth scheme from API.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The auth_scheme parameter in the initiate_connection function was changed from a default value of "OAUTH2" to None. This allows the function to dynamically fetch the default auth scheme from the API if not provided, which is a more flexible approach.
3. python/composio/tools/toolset.py:1401
  • Draft comment:
    Updated auth_scheme check to handle None values appropriately.
  • Reason this comment was not posted:
    Confidence changes required: 0%
    The check for auth_scheme in initiate_connection was updated to handle None values, which is necessary due to the change in default value. This ensures that the function behaves correctly when auth_scheme is not provided.

Workflow ID: wflow_B2UyytUUhPMkufKP


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

@@ -1384,7 +1384,7 @@ def initiate_connection(
redirect_url: t.Optional[str] = None,
connected_account_params: t.Optional[t.Dict] = None,
*,
auth_scheme: AuthSchemeType = "OAUTH2",
auth_scheme: t.Optional[AuthSchemeType] = None,
Copy link
Collaborator

Choose a reason for hiding this comment

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

The docstring for initiate_connection should be updated to reflect that auth_scheme is now optional and will be fetched from the API if not provided. This helps maintain clear documentation for future developers.

@shreysingla11
Copy link
Collaborator

Code Review Summary

Overall Assessment

The changes look good and improve the authentication scheme handling by making it more flexible and user-friendly. The code is clean and the error messages are more informative.

Strengths

✅ Good error message improvements using repr() for better clarity
✅ Removal of duplicate auth_scheme validation
✅ Clean implementation of default auth scheme fetching
✅ Backward compatible changes

Suggestions for Improvement

  1. Update the docstring for initiate_connection to reflect the new optional behavior
  2. Add error handling and logging around the default auth scheme fetching
  3. Consider standardizing error message formatting across the codebase (some use backticks, others use repr())

Testing Recommendations

  • Add tests for automatic auth scheme selection
  • Test error cases when API calls fail
  • Verify backward compatibility with existing code

The changes are well-structured and improve the codebase. With the suggested improvements implemented, this PR will be ready to merge.

Copy link

github-actions bot commented Nov 23, 2024

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-11985522976/coverage/index.html

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

@tushar-composio tushar-composio enabled auto-merge (squash) November 23, 2024 07:21
@tushar-composio tushar-composio merged commit 31f363d into master Nov 23, 2024
9 checks passed
@tushar-composio tushar-composio deleted the ENG-2538 branch November 23, 2024 08:25
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