@devries-cameron20 / composio-1 / commits / 656625f88
Fork 0

Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.

fix(py): align auth config responses with generated client types (#4616)

This PR: - Replaces `Dict` return annotations and casts on Python auth-config update, delete, enable, and disable with the public response models from the existing `composio-client==2.0.0rc8` dependency. - Preserves the Pydantic objects returned at runtime, including typed `success` and `message` fields and `model_dump()`; exports the response modules through `composio.client.types`. - Corrects mock responses and adds real-client HTTP parsing tests plus static assertions for both update overloads and the other mutation results. - Provides the RC.8-based alternative to https://github.com/ComposioHQ/composio/pull/4610, whose proposed `id`/`status` dictionary does not describe the actual response. ## Validation - `pytest tests/test_auth_configs.py -q`: 37 passed, both from the source checkout and against an independently installed wheel. - `mypy --config-file config/mypy.ini composio/ tests/test_type_inference.py tests/test_auth_configs.py`: 64 files passed. The new assertions fail with 17 errors against the previous annotations. - Built the sdist and wheel using `python -m build`; installed the wheel in a clean consumer environment with RC.8. Strict consumer type checks pass; negative checks reject dictionary indexing and nonexistent `id`/`status` attributes. `uv pip check` passes. - Authenticated smoke test against `backend.composio.dev` using the installed wheel: list, create, get, update, disable, enable, delete. All four mutation results match the exact annotated generated classes, and the raw HTTP payloads pass strict Pydantic validation. Only a newly created test auth config was mutated; cleanup was verified with a subsequent HTTP 404. The custom update overload is covered offline; the live update used managed auth. - Ruff, `git diff --check`, agent-skill validation, and skill-routing checks pass.

Alberto Schiabel committed Sep 24, 2026 at 11:48 UTC 656625f88bb0b38fd80c1ca04705d6ba21172799
4 files changed +198 -47
python/composio/client/types.py
+7 -1
@@ -8,12 +8,15 @@ from composio_client import NotGiven
8 from composio_client.types import (
9 auth_config_create_params,
10 auth_config_create_response,
11 + auth_config_delete_response,
12 auth_config_list_params,
13 auth_config_list_response,
14 auth_config_retrieve_response,
15 auth_config_update_params,
15 - connected_account_create_params,
16 + auth_config_update_response,
17 + auth_config_update_status_response,
18 connected_account_complete_auth_response,
19 + connected_account_create_params,
20 connected_account_create_response,
21 connected_account_list_params,
22 connected_account_list_response,
@@ -115,10 +118,13 @@ AuthSchemeL: t.TypeAlias = t.Literal[
118 __all__ = (
119 "auth_config_create_params",
120 "auth_config_create_response",
121 + "auth_config_delete_response",
122 "auth_config_list_params",
123 "auth_config_list_response",
124 "auth_config_retrieve_response",
125 "auth_config_update_params",
126 + "auth_config_update_response",
127 + "auth_config_update_status_response",
128 "connected_account_complete_auth_response",
129 "connected_account_create_params",
130 "connected_account_create_response",
python/composio/core/models/auth_configs.py
+31 -32
@@ -7,10 +7,13 @@ import typing_extensions as te
7 from composio.client.types import (
8 auth_config_create_params,
9 auth_config_create_response,
10 + auth_config_delete_response,
11 auth_config_list_params,
12 auth_config_list_response,
13 auth_config_retrieve_response,
14 auth_config_update_params,
15 + auth_config_update_response,
16 + auth_config_update_status_response,
17 )
18 from composio.core.models.base import Resource
19
@@ -67,17 +70,16 @@ class AuthConfigs(Resource):
70 @t.overload
71 def update(
72 self, nanoid: str, *, options: auth_config_update_params.Variant0
70 - ) -> t.Dict: ...
73 + ) -> auth_config_update_response.AuthConfigUpdateResponse: ...
74
75 @t.overload
76 def update(
77 self, nanoid: str, *, options: auth_config_update_params.Variant1
75 - ) -> t.Dict: ...
78 + ) -> auth_config_update_response.AuthConfigUpdateResponse: ...
79
77 - # FIXME: what type is this response, in ts, it's AuthConfigUpdateResponse
80 def update(
81 self, nanoid: str, *, options: auth_config_update_params.AuthConfigUpdateParams
80 - ) -> t.Dict:
82 + ) -> auth_config_update_response.AuthConfigUpdateResponse:
83 """
84 Updates an existing authentication configuration.
85
@@ -87,59 +89,56 @@ class AuthConfigs(Resource):
89
90 :param nanoid: The ID of the auth config to update.
91 :param options: The options to update the auth config with.
90 - :return: The updated auth config.
92 + :return: The update result with success and message fields.
93 """
92 - return t.cast(
93 - t.Dict,
94 - self._client.auth_configs.update(
95 - nanoid=nanoid,
96 - type=options["type"], # type: ignore
97 - credentials=options.get("credentials", self._client.not_given),
98 - is_enabled_for_tool_router=options.get(
99 - "is_enabled_for_tool_router", self._client.not_given
100 - ),
101 - tool_access_config=options.get(
102 - "tool_access_config", self._client.not_given
103 - ),
94 + return self._client.auth_configs.update(
95 + nanoid=nanoid,
96 + type=options["type"], # type: ignore
97 + credentials=options.get("credentials", self._client.not_given),
98 + is_enabled_for_tool_router=options.get(
99 + "is_enabled_for_tool_router", self._client.not_given
100 + ),
101 + tool_access_config=options.get(
102 + "tool_access_config", self._client.not_given
103 ),
104 )
105
107 - def delete(self, nanoid: str) -> t.Dict:
106 + def delete(
107 + self, nanoid: str
108 + ) -> auth_config_delete_response.AuthConfigDeleteResponse:
109 """
110 Deletes an existing authentication configuration.
111
112 :param nanoid: The ID of the auth config to delete.
112 - :return: The deleted auth config.
113 + :return: The deletion result with success and message fields.
114 """
114 - return t.cast(t.Dict, self._client.auth_configs.delete(nanoid))
115 + return self._client.auth_configs.delete(nanoid)
116
117 def __update_status(
118 self,
119 nanoid: str,
120 status: t.Literal["ENABLED", "DISABLED"],
120 - ) -> t.Dict:
121 - return t.cast(
122 - t.Dict,
123 - self._client.auth_configs.update_status(
124 - status,
125 - nanoid=nanoid,
126 - ),
127 - )
121 + ) -> auth_config_update_status_response.AuthConfigUpdateStatusResponse:
122 + return self._client.auth_configs.update_status(status, nanoid=nanoid)
123
129 - def enable(self, nanoid: str) -> t.Dict:
124 + def enable(
125 + self, nanoid: str
126 + ) -> auth_config_update_status_response.AuthConfigUpdateStatusResponse:
127 """
128 Enables an existing authentication configuration.
129
130 :param nanoid: The ID of the auth config to enable.
134 - :return: The enabled auth config.
131 + :return: The status update result with success and message fields.
132 """
133 return self.__update_status(nanoid, "ENABLED")
134
138 - def disable(self, nanoid: str) -> t.Dict:
135 + def disable(
136 + self, nanoid: str
137 + ) -> auth_config_update_status_response.AuthConfigUpdateStatusResponse:
138 """
139 Disables an existing authentication configuration.
140
141 :param nanoid: The ID of the auth config to disable.
143 - :return: The disabled auth config.
142 + :return: The status update result with success and message fields.
143 """
144 return self.__update_status(nanoid, "DISABLED")
python/tests/test_auth_configs.py
+121 -12
@@ -2,14 +2,19 @@
2
3 from unittest.mock import Mock
4
5 +import httpx
6 import pytest
6 -
7 +from composio.client import HttpClient
8 from composio.client.types import (
9 auth_config_create_response,
10 + auth_config_delete_response,
11 auth_config_list_response,
12 auth_config_retrieve_response,
13 + auth_config_update_response,
14 + auth_config_update_status_response,
15 )
16 from composio.core.models.auth_configs import AuthConfigs
17 +from pydantic import BaseModel
18
19
20 class TestAuthConfigs:
@@ -266,7 +271,9 @@ class TestAuthConfigs:
271 self, auth_configs, mock_client
272 ):
273 """Test updating custom auth config with credentials."""
269 - mock_response = {"id": "auth_12345", "status": "success"}
274 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
275 + success=True, message="Successfully updated auth config"
276 + )
277 mock_client.auth_configs.update.return_value = mock_response
278
279 options = {
@@ -288,7 +295,9 @@ class TestAuthConfigs:
295
296 def test_update_default_auth_config_with_scopes(self, auth_configs, mock_client):
297 """Test updating default auth config with scopes."""
291 - mock_response = {"id": "auth_12345", "status": "success"}
298 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
299 + success=True, message="Successfully updated auth config"
300 + )
301 mock_client.auth_configs.update.return_value = mock_response
302
303 options = {
@@ -307,7 +316,9 @@ class TestAuthConfigs:
316
317 def test_update_with_is_enabled_for_tool_router(self, auth_configs, mock_client):
318 """Test updating auth config with isEnabledForToolRouter."""
310 - mock_response = {"id": "auth_12345", "status": "success"}
319 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
320 + success=True, message="Successfully updated auth config"
321 + )
322 mock_client.auth_configs.update.return_value = mock_response
323
324 options = {
@@ -324,7 +335,9 @@ class TestAuthConfigs:
335
336 def test_update_with_tool_access_config(self, auth_configs, mock_client):
337 """Test updating auth config with tool access configuration."""
327 - mock_response = {"id": "auth_12345", "status": "success"}
338 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
339 + success=True, message="Successfully updated auth config"
340 + )
341 mock_client.auth_configs.update.return_value = mock_response
342
343 options = {
@@ -343,7 +356,9 @@ class TestAuthConfigs:
356
357 def test_update_with_large_credential_object(self, auth_configs, mock_client):
358 """Test updating auth config with large credential object."""
346 - mock_response = {"id": "auth_12345", "status": "success"}
359 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
360 + success=True, message="Successfully updated auth config"
361 + )
362 mock_client.auth_configs.update.return_value = mock_response
363
364 large_credentials = {
@@ -383,7 +398,9 @@ class TestAuthConfigs:
398 # Delete tests
399 def test_delete_auth_config_by_id(self, auth_configs, mock_client):
400 """Test deleting auth config by ID."""
386 - mock_response = {"id": "auth_12345", "status": "deleted"}
401 + mock_response = auth_config_delete_response.AuthConfigDeleteResponse(
402 + success=True, message="Successfully deleted auth config"
403 + )
404 mock_client.auth_configs.delete.return_value = mock_response
405
406 result = auth_configs.delete("auth_12345")
@@ -403,7 +420,11 @@ class TestAuthConfigs:
420 # Enable/Disable tests
421 def test_enable_auth_config(self, auth_configs, mock_client):
422 """Test enabling auth config."""
406 - mock_response = {"id": "auth_12345", "status": "ENABLED"}
423 + mock_response = (
424 + auth_config_update_status_response.AuthConfigUpdateStatusResponse(
425 + success=True, message="Successfully updated auth config status"
426 + )
427 + )
428 mock_client.auth_configs.update_status.return_value = mock_response
429
430 result = auth_configs.enable("auth_12345")
@@ -415,7 +436,11 @@ class TestAuthConfigs:
436
437 def test_disable_auth_config(self, auth_configs, mock_client):
438 """Test disabling auth config."""
418 - mock_response = {"id": "auth_12345", "status": "DISABLED"}
439 + mock_response = (
440 + auth_config_update_status_response.AuthConfigUpdateStatusResponse(
441 + success=True, message="Successfully updated auth config status"
442 + )
443 + )
444 mock_client.auth_configs.update_status.return_value = mock_response
445
446 result = auth_configs.disable("auth_12345")
@@ -446,7 +471,9 @@ class TestAuthConfigs:
471 # Edge cases
472 def test_update_with_missing_optional_fields(self, auth_configs, mock_client):
473 """Test update works with only required fields."""
449 - mock_response = {"id": "auth_12345", "status": "success"}
474 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
475 + success=True, message="Successfully updated auth config"
476 + )
477 mock_client.auth_configs.update.return_value = mock_response
478
479 options = {
@@ -565,7 +592,9 @@ class TestAuthConfigsOverloads:
592
593 def test_update_overload_custom_type(self, auth_configs, mock_client):
594 """Test update with custom type."""
568 - mock_response = {"id": "auth_12345", "status": "success"}
595 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
596 + success=True, message="Successfully updated auth config"
597 + )
598 mock_client.auth_configs.update.return_value = mock_response
599
600 options = {
@@ -578,7 +607,9 @@ class TestAuthConfigsOverloads:
607
608 def test_update_overload_default_type(self, auth_configs, mock_client):
609 """Test update with default type."""
581 - mock_response = {"id": "auth_12345", "status": "success"}
610 + mock_response = auth_config_update_response.AuthConfigUpdateResponse(
611 + success=True, message="Successfully updated auth config"
612 + )
613 mock_client.auth_configs.update.return_value = mock_response
614
615 options = {
@@ -588,3 +619,81 @@ class TestAuthConfigsOverloads:
619 result = auth_configs.update("auth_12345", options=options)
620
621 assert result == mock_response
622 +
623 +
624 +@pytest.mark.parametrize(
625 + ("operation", "method", "path", "response_type"),
626 + [
627 + (
628 + "update_custom",
629 + "PATCH",
630 + "/api/v3.1/auth_configs/ac_test",
631 + auth_config_update_response.AuthConfigUpdateResponse,
632 + ),
633 + (
634 + "update_default",
635 + "PATCH",
636 + "/api/v3.1/auth_configs/ac_test",
637 + auth_config_update_response.AuthConfigUpdateResponse,
638 + ),
639 + (
640 + "delete",
641 + "DELETE",
642 + "/api/v3.1/auth_configs/ac_test",
643 + auth_config_delete_response.AuthConfigDeleteResponse,
644 + ),
645 + (
646 + "enable",
647 + "PATCH",
648 + "/api/v3.1/auth_configs/ac_test/ENABLED",
649 + auth_config_update_status_response.AuthConfigUpdateStatusResponse,
650 + ),
651 + (
652 + "disable",
653 + "PATCH",
654 + "/api/v3.1/auth_configs/ac_test/DISABLED",
655 + auth_config_update_status_response.AuthConfigUpdateStatusResponse,
656 + ),
657 + ],
658 +)
659 +def test_mutation_response_through_generated_client(
660 + operation, method, path, response_type
661 +):
662 + """Parse HTTP through the real client instead of mocking its return value."""
663 + payload = {"success": True, "message": "Successfully updated auth config"}
664 + requests = []
665 +
666 + def handler(request: httpx.Request) -> httpx.Response:
667 + requests.append(request)
668 + return httpx.Response(200, json=payload)
669 +
670 + with HttpClient(
671 + provider="test",
672 + api_key="test",
673 + _environment_variables={},
674 + http_client=httpx.Client(transport=httpx.MockTransport(handler)),
675 + ) as client:
676 + auth_configs = AuthConfigs(client)
677 + calls = {
678 + "update_custom": lambda: auth_configs.update(
679 + "ac_test",
680 + options={"type": "custom", "credentials": {"scopes": "read:user"}},
681 + ),
682 + "update_default": lambda: auth_configs.update(
683 + "ac_test",
684 + options={"type": "default", "is_enabled_for_tool_router": True},
685 + ),
686 + "delete": lambda: auth_configs.delete("ac_test"),
687 + "enable": lambda: auth_configs.enable("ac_test"),
688 + "disable": lambda: auth_configs.disable("ac_test"),
689 + }
690 + result = calls[operation]()
691 +
692 + assert len(requests) == 1
693 + assert requests[0].method == method
694 + assert requests[0].url.path == path
695 + assert isinstance(result, response_type)
696 + assert isinstance(result, BaseModel)
697 + assert result.success is True
698 + assert result.message == payload["message"]
699 + assert result.model_dump(exclude_unset=True) == payload
python/tests/test_type_inference.py
+39 -2
@@ -29,9 +29,8 @@ from composio.core.provider._openai_responses import (
29 )
30
31 if TYPE_CHECKING:
32 - from typing_extensions import assert_type
33 -
32 from openai.types.chat.chat_completion_tool_param import ChatCompletionToolParam
33 + from typing_extensions import assert_type
34
35
36 def test_openai_provider_explicit() -> None:
@@ -114,3 +113,41 @@ def test_openai_responses_provider_explicit() -> None:
113 tools = composio.tools.get(user_id="test", toolkits=["github"])
114
115 assert_type(tools, list[dict[str, Any]])
116 +
117 +
118 +def test_auth_config_response_types() -> None:
119 + """SDK mutation results retain the generated client's Pydantic types."""
120 + if TYPE_CHECKING:
121 + from composio_client.types.auth_config_delete_response import (
122 + AuthConfigDeleteResponse,
123 + )
124 + from composio_client.types.auth_config_update_response import (
125 + AuthConfigUpdateResponse,
126 + )
127 + from composio_client.types.auth_config_update_status_response import (
128 + AuthConfigUpdateStatusResponse,
129 + )
130 +
131 + composio = Composio()
132 + custom = composio.auth_configs.update(
133 + "ac_test",
134 + options={"type": "custom", "credentials": {"scopes": "read:user"}},
135 + )
136 + default = composio.auth_configs.update(
137 + "ac_test", options={"type": "default", "is_enabled_for_tool_router": True}
138 + )
139 + deleted = composio.auth_configs.delete("ac_test")
140 + enabled = composio.auth_configs.enable("ac_test")
141 + disabled = composio.auth_configs.disable("ac_test")
142 +
143 + assert_type(custom, AuthConfigUpdateResponse)
144 + assert_type(default, AuthConfigUpdateResponse)
145 + assert_type(deleted, AuthConfigDeleteResponse)
146 + assert_type(enabled, AuthConfigUpdateStatusResponse)
147 + assert_type(disabled, AuthConfigUpdateStatusResponse)
148 + assert_type(custom.success, bool)
149 + assert_type(default.message, str)
150 + assert_type(deleted.revoke_job_id, str | None)
151 + assert_type(enabled.success, bool)
152 + assert_type(disabled.message, str)
153 + assert_type(custom.model_dump(), dict[str, Any])