@devries-cameron20 / composio Mirror · read-only / commits / d162f7aa6
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.

Mirrored from https://github.com/Camo67/composio.git

Synced Nov 21, 21:00 UTC

fix(connected-accounts): SEC-339 gate initiate() warning on response Deprecation header (#3380)

## Summary Fixes the false-positive `initiate()` deprecation warning that the SDK fired for **custom** OAuth auth configs, even though those configs are not subject to the SEC-339 retirement (only Composio-managed + redirectable OAuth is). This is a follow-up to ComposioHQ/composio#3289 (which introduced the warning) and pairs with ComposioHQ/hermes#NEW-PR (the apollo header-contract test). ## What was wrong The TypeScript and Python SDKs fired their one-time deprecation warning whenever the response carried a redirectable OAuth scheme (`OAUTH1`, `OAUTH2`, `DCR_OAUTH`), regardless of whether the auth config was Composio-managed (subject to the **2026-07-03** cutover) or custom (unaffected). The warning text was conditional ("If this auth config is Composio-managed…") so callers using their own OAuth apps could ignore it, but the warning still printed and caused noise in their logs. ## What changed Apollo already emits the SEC-339 `Deprecation` (RFC 9745), `Sunset` (RFC 8594), and `Link rel="deprecation"` headers **only** on the retiring branch — managed + redirectable OAuth + LD didn't block. The SDKs now read the `Deprecation` header from the response and gate the warning on its presence. Custom auth configs and non-OAuth schemes get a clean response from the server and now stay silent in the SDK as well. ### TypeScript (`@composio/core`) - Chain `.withResponse()` on the underlying `client.connectedAccounts.create` call to expose the raw `Response`. Defensive fallback for unit tests that mock `create()` as a plain Promise (so existing initiate tests keep passing). - Drop `LEGACY_RETIRING_OAUTH_SCHEMES`; the apollo header is now the sole signal. - New tests in `describe('initiate deprecation header gate', …)` pin the contract: - **warns once** when `Deprecation` is present (managed-OAuth retiring path) - **silent** when `Deprecation` is absent (custom auth config — the regression we're fixing) - **at most once per process** even across multiple managed-OAuth calls - A `mockApiPromiseWithHeaders()` helper wraps mocked values as `APIPromise`-shaped thenables so the new tests can simulate apollo's header behavior. ### Python (`composio`) - Switch to `client.connected_accounts.with_raw_response.create(...)` so we can read `raw.headers.get('Deprecation')`. Defensive fallback for test mocks that don't stub `with_raw_response`. - Drop `_LEGACY_RETIRING_OAUTH_SCHEMES`; same simplification as TS. - New `TestInitiateDeprecationHeaderGate` class with the same three pinning cases. - A `_set_initiate_response()` helper routes mock responses through the `with_raw_response` surface that `initiate()` now consumes. Pre-existing initiate tests migrated to the helper; one assertion that inspected `create.call_args.kwargs` now reads `with_raw_response.create.call_args.kwargs`. ## What does NOT change - Public API for either SDK: `initiate()` returns the same `ConnectionRequest` shape and respects the same `allowMultiple` / `allow_multiple` guard. - `ComposioLegacyConnectedAccountsEndpointRetiredError` continues to surface from the 400 retired-path response. - Behavior for managed-OAuth callers: still warned once per process (with revised wording that points at the response's `Sunset` header for the precise cutover date). ## Validation - `pnpm exec tsc --noEmit` in `ts/packages/core` — zero errors from this diff (one pre-existing baseline error in `utils/jsonSchema.ts` from local workspace-build state, unrelated to this change). - `pytest tests/test_connected_accounts.py` — all 37 tests pass (3 new + 34 pre-existing, including the migrated `test_initiate_*` tests). - `ruff check`, `ruff format --check` — clean on both edited files. - `pnpm exec prettier --check` — clean on edited TS files. - Vitest run blocked locally on a rolldown native-binding ABI mismatch in this dev environment; CI will run the full suite. Mock setup mirrors the existing `connectedAccounts.test.ts` patterns. ## Changeset `.changeset/sec-339-deprecation-header-gate.md` bumps `@composio/core` as a **patch**. Python SDK gets the matching change in the same release train. ## Migration / rollout No customer-facing migration needed. The behavior change is "fewer false-positive log lines for custom-auth-config callers," which is strictly better. Composio-managed OAuth callers continue to be informed of the cutover with revised wording.

lingalarahul7 committed May 8, 2026 at 18:17 UTC d162f7aa6e74ecef4daae201d134572ffc0572f0

No changes.