ComposioHQ / composio

Composio equip's your AI agents & LLMs with 100+ high-quality integrations via function calling
https://docs.composio.dev
Other
7.47k stars 2.33k forks source link

feat: add support for configuring BASE_URL using COMPOSIO_BASE_URL env #337

Closed utkarsh-dixit closed 1 month ago

utkarsh-dixit commented 1 month ago

User description

…v variable


PR Type

Enhancement


Description


Changes walkthrough πŸ“

Relevant files
Enhancement
OpenAPI.ts
Make BASE URL configurable via environment variable           

js/src/sdk/client/core/OpenAPI.ts
  • Changed BASE URL to be configurable via COMPOSIO_BASE_URL environment
    variable.
  • +1/-1     
    index.ts
    Update baseUrl initialization and methods to use environment variable

    js/src/sdk/index.ts
  • Updated baseUrl initialization to use COMPOSIO_BASE_URL environment
    variable.
  • Changed getApiUrlBase to a static method and made it use
    COMPOSIO_BASE_URL.
  • Updated methods to use the new getApiUrlBase static method.
  • +5/-5     
    Versioning
    package.json
    Bump package version to 0.1.6-1                                                   

    js/package.json - Updated package version from `0.1.5` to `0.1.6-1`.
    +1/-1     

    πŸ’‘ PR-Agent usage: Comment /help on the PR to get a list of all available PR-Agent tools and their descriptions

    ellipsis-dev[bot] commented 1 month ago

    Your free trial has expired. To keep using Ellipsis, sign up at https://app.ellipsis.dev for $20/seat/month or reach us at help@ellipsis.dev

    codiumai-pr-agent-pro[bot] commented 1 month ago

    PR Reviewer Guide πŸ”

    ⏱️ Estimated effort to review: 2 πŸ”΅πŸ”΅βšͺβšͺβšͺ
    πŸ§ͺ No relevant tests
    πŸ”’ No security concerns identified
    ⚑ Key issues to review

    Hardcoded Fallback URL
    The fallback URL 'https://backend.composio.dev/api' is hardcoded. Consider making it configurable or documenting why this specific URL is used as a fallback. Method Conversion
    Conversion of 'getApiUrlBase' from a private instance method to a public static method could lead to unintended usage or side effects. Review the access level and usage across the project.
    codiumai-pr-agent-pro[bot] commented 1 month ago

    PR Code Suggestions ✨

    CategorySuggestion                                                                                                                                    Score
    Security
    βœ… Add a check for COMPOSIO_BASE_URL to enhance security and debugging ___
    Suggestion Impact:The commit added a utility function `getEnvVariable` to handle environment variables, including `COMPOSIO_BASE_URL`, which aligns with the suggestion to check for the presence of `COMPOSIO_BASE_URL` before using it. code diff: ```diff static getApiUrlBase(): string { - return process.env.COMPOSIO_BASE_URL || 'https://backend.composio.dev/api'; + return getEnvVariable("COMPOSIO_BASE_URL", 'https://backend.composio.dev/api') as string; ```
    ___ **To avoid potential security risks, explicitly check for the presence of
    COMPOSIO_BASE_URL before using it. If it's not set, log a warning or throw an error.** [js/src/sdk/index.ts [69]](https://github.com/ComposioHQ/composio/pull/337/files#diff-de82114af414fc4b45690c3f12d436b62d6270bd11e7b985bc37de196609651eR69-R69) ```diff +if (!process.env.COMPOSIO_BASE_URL) { + console.warn('COMPOSIO_BASE_URL is not set. Using default URL.'); +} return process.env.COMPOSIO_BASE_URL || 'https://backend.composio.dev/api'; ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 9 Why: Adding a check for the presence of `COMPOSIO_BASE_URL` enhances security and provides better debugging information. This is a valuable improvement.
    9
    Best practice
    Improve environment variable naming for clarity and compatibility ___ **Consider using a more specific environment variable name or prefixing it with
    REACT_APP_ to ensure it is included during the build process in environments like
    Create React App. This change enhances clarity and compatibility.** [js/src/sdk/client/core/OpenAPI.ts [43]](https://github.com/ComposioHQ/composio/pull/337/files#diff-869b16570245c550781ad327f96ca31ba0739c58b47b0ee310082f1c852955f3R43-R43) ```diff -BASE: process.env.COMPOSIO_BASE_URL || 'https://backend.composio.dev/api', +BASE: process.env.REACT_APP_COMPOSIO_BASE_URL || 'https://backend.composio.dev/api', ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 8 Why: This suggestion improves the clarity and compatibility of the environment variable, especially in environments like Create React App. It is a best practice to use a more specific name or prefix.
    8
    Maintainability
    Refactor to reduce redundancy and improve maintainability ___ **Refactor the repeated use of baseUrl || this.getApiUrlBase() by creating a helper
    function to get the effective base URL. This will improve code maintainability and
    reduce redundancy.** [js/src/sdk/index.ts [74]](https://github.com/ComposioHQ/composio/pull/337/files#diff-de82114af414fc4b45690c3f12d436b62d6270bd11e7b985bc37de196609651eR74-R74) ```diff -baseURL: baseUrl || this.getApiUrlBase(), +baseURL: getEffectiveBaseUrl(baseUrl), ``` - [ ] **Apply this suggestion**
    Suggestion importance[1-10]: 7 Why: Creating a helper function to get the effective base URL reduces redundancy and improves maintainability. However, the actual implementation of the helper function is not provided, so the suggestion is partially incomplete.
    7
    codiumai-pr-agent-pro[bot] commented 1 month ago

    CI Failure Feedback 🧐

    (Checks updated until commit https://github.com/ComposioHQ/composio/commit/f57c5a3181bf18dfba009856f0715f3eea68bd09)

    **Action:** test (ubuntu-latest, 3.10)
    **Failed stage:** [Unittests](https://github.com/ComposioHQ/composio/actions/runs/10020280749/job/27697748839) [❌]
    **Failed test name:** test_action_enum
    **Failure summary:** The action failed because the test test_action_enum in the file tests/test_client/test_enum.py
    raised a ValueError.
  • The error message was: "Invalid value GITHUB_ISSUES_LIST for Action".
  • This indicates that the value GITHUB_ISSUES_LIST is not a valid value for the Action enum.
  • Relevant error logs: ```yaml 1: ##[group]Operating System 2: Ubuntu ... 506: * [new branch] fix/readme -> origin/fix/readme 507: * [new branch] fix/readme-logo -> origin/fix/readme-logo 508: * [new branch] fix/swe-agent -> origin/fix/swe-agent 509: * [new branch] ft-add-better-help-text -> origin/ft-add-better-help-text 510: * [new branch] ft-apps-id -> origin/ft-apps-id 511: * [new branch] ft-bring-back-core-sdk -> origin/ft-bring-back-core-sdk 512: * [new branch] ft-custom-base-url-js-sdk -> origin/ft-custom-base-url-js-sdk 513: * [new branch] ft-did-you-mean -> origin/ft-did-you-mean 514: * [new branch] ft-error-tracking -> origin/ft-error-tracking ... 930: tests/test_cli/test_actions.py::TestListActions::test_list_all[arguments3-exptected_outputs3-unexptected_outputs3] PASSED [ 17%] 931: tests/test_cli/test_actions.py::TestListActions::test_tag_not_found PASSED [ 19%] 932: tests/test_cli/test_actions.py::TestListActions::test_limit SKIPPED [ 21%] 933: tests/test_cli/test_actions.py::TestListActions::test_copy PASSED [ 23%] 934: tests/test_cli/test_add.py::TestComposioAdd::test_no_auth PASSED [ 25%] 935: tests/test_cli/test_apps.py::TestList::test_list PASSED [ 27%] 936: tests/test_cli/test_apps.py::TestUpdate::test_update_not_required PASSED [ 29%] 937: tests/test_cli/test_apps.py::TestUpdate::test_update SKIPPED (Needs 938: investigation, this test fails in CI) [ 31%] ... 946: tests/test_client/test_client.py::test_raise_invalid_api_key PASSED [ 48%] 947: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_trigger_objects_to_comma_separated_string PASSED [ 51%] 948: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_trigger_strings_to_comma_separated_string PASSED [ 53%] 949: tests/test_client/test_collections.py::TestTriggerNamesSerialization::test_converts_mix_of_trigger_objects_and_strings PASSED [ 55%] 950: tests/test_client/test_collections.py::test_trigger_subscription PASSED [ 57%] 951: tests/test_client/test_endpoints.py::test_endpoint PASSED [ 59%] 952: tests/test_client/test_enum.py::test_tag_enum PASSED [ 61%] 953: tests/test_client/test_enum.py::test_app_enum PASSED [ 63%] 954: tests/test_client/test_enum.py::test_action_enum FAILED [ 65%] ... 963: tests/test_tools/test_local/test_workspace.py::test_stderr PASSED [ 85%] 964: tests/test_tools/test_local/test_workspace.py::test_workspace PASSED [ 87%] 965: tests/test_utils/test_decorators.py::test_deprecated PASSED [ 89%] 966: tests/test_utils/test_git.py::test_get_git_user_info PASSED [ 91%] 967: tests/test_utils/test_shared.py::test_get_pydantic_signature_format_from_schema_params PASSED [ 93%] 968: tests/test_utils/test_shared.py::test_json_schema_to_pydantic_field PASSED [ 95%] 969: tests/test_utils/test_shared.py::test_json_schema_to_fields_dict PASSED [ 97%] 970: tests/test_utils/test_url.py::test_get_web_url PASSED [100%] 971: =================================== FAILURES =================================== ... 981: self = 982: value = 'GITHUB_ISSUES_LIST' 983: def __init__(self, value: t.Union[str, te.Self]) -> None: 984: """Create an Enum""" 985: if isinstance(value, _AnnotatedEnum): 986: value = value._slug 987: value = t.cast(str, value).upper() 988: if value not in self.__annotations__ and value not in _runtime_actions: 989: > raise ValueError(f"Invalid value `{value}` for `{self.__class__.__name__}`") 990: E ValueError: Invalid value `GITHUB_ISSUES_LIST` for `Action` 991: composio/client/enums/base.py:112: ValueError 992: =============================== warnings summary =============================== 993: composio/client/http.py:20 994: /home/runner/work/composio/composio/python/composio/client/http.py:20: DeprecationWarning: Inheritance class AsyncHttpClient from ClientSession is discouraged 995: class AsyncHttpClient(AsyncSession, logging.WithLogger): 996: .tox/unittests/lib/python3.10/site-packages/pydantic/_internal/_config.py:291 997: .tox/unittests/lib/python3.10/site-packages/pydantic/_internal/_config.py:291 998: /home/runner/work/composio/composio/python/.tox/unittests/lib/python3.10/site-packages/pydantic/_internal/_config.py:291: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.8/migration/ ... 1188: composio/utils/shared.py 118 84 29% 44, 47-51, 54-58, 61-77, 83, 101-104, 153-158, 174-221, 247-293 1189: composio/utils/url.py 10 1 90% 35 1190: examples/crewai_ci_chart.py 15 15 0% 1-38 1191: -------------------------------------------------------------------------------------------------------------- 1192: TOTAL 9934 2267 77% 1193: Coverage HTML written to dir htmlcov 1194: Coverage XML written to file coverage.xml 1195: =========================== short test summary info ============================ 1196: FAILED tests/test_client/test_enum.py::test_action_enum - ValueError: Invalid value `GITHUB_ISSUES_LIST` for `Action` 1197: ============= 1 failed, 41 passed, 5 skipped, 3 warnings in 41.40s ============= 1198: unittests: exit 1 (42.55 seconds) /home/runner/work/composio/composio/python> pytest -vvv -rfE --doctest-modules composio/ tests/ --cov=composio --cov=examples --cov-report=html --cov-report=xml --cov-report=term --cov-report=term-missing --cov-config=.coveragerc pid=5763 1199: .pkg: _exit> python /opt/hostedtoolcache/Python/3.10.14/x64/lib/python3.10/site-packages/pyproject_api/_backend.py True setuptools.build_meta __legacy__ 1200: unittests: FAIL code 1 (87.57=setup[39.50]+cmd[5.52,42.55] seconds) 1201: evaluation failed :( (87.90 seconds) 1202: ##[error]Process completed with exit code 1. ```

    ✨ CI feedback usage guide:
    The CI feedback tool (`/checks)` automatically triggers when a PR has a failed check. The tool analyzes the failed checks and provides several feedbacks: - Failed stage - Failed test name - Failure summary - Relevant error logs In addition to being automatically triggered, the tool can also be invoked manually by commenting on a PR: ``` /checks "https://github.com/{repo_name}/actions/runs/{run_number}/job/{job_number}" ``` where `{repo_name}` is the name of the repository, `{run_number}` is the run number of the failed check, and `{job_number}` is the job number of the failed check. #### Configuration options - `enable_auto_checks_feedback` - if set to true, the tool will automatically provide feedback when a check is failed. Default is true. - `excluded_checks_list` - a list of checks to exclude from the feedback, for example: ["check1", "check2"]. Default is an empty list. - `enable_help_text` - if set to true, the tool will provide a help message with the feedback. Default is true. - `persistent_comment` - if set to true, the tool will overwrite a previous checks comment with the new feedback. Default is true. - `final_update_message` - if `persistent_comment` is true and updating a previous checks message, the tool will also create a new message: "Persistent checks updated to latest commit". Default is true. See more information about the `checks` tool in the [docs](https://pr-agent-docs.codium.ai/tools/ci_feedback/).