@devries-cameron20 / composio-1 / commits / c358ffaa3
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(connected-accounts): SEC-339 gate initiate() warning on response Deprecation header

initiate() previously emitted a 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 wording 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 added noise to logs. Apollo already emits the SEC-339 'Deprecation' / 'Sunset' / 'Link rel="deprecation"' headers (RFC 9745 / RFC 8594) 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. TS: - Chain '.withResponse()' on the underlying client.connectedAccounts.create call to expose the raw Response. Defensive fallback for tests that mock create() as a plain Promise. - Drop the LEGACY_RETIRING_OAUTH_SCHEMES set; the apollo header is now the sole signal. - New tests in describe('initiate deprecation header gate', ...) pin the contract: warns when Deprecation is present, silent when absent, and one-time-per-process even across multiple managed-OAuth calls. A mockApiPromiseWithHeaders helper wraps mocked values as APIPromise-shape thenables so the new tests can simulate apollo's header behavior. Python: - Switch to client.connected_accounts.with_raw_response.create so we can read raw.headers.get('Deprecation'). Defensive fallback to the parsed- only path 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. No public API change for either SDK — initiate() returns the same ConnectionRequest shape and respects the same allowMultiple guard. ComposioLegacyConnectedAccountsEndpointRetiredError continues to surface from the 400 retired-path response. Changeset bumps @composio/core as a patch.

Composio committed May 8, 2026 at 15:18 UTC c358ffaa3b22cce23b0a4fcd06f220072fe7df68
5 files changed +339 -55
.changeset/sec-339-deprecation-header-gate.md new
+15
@@ -0,0 +1,15 @@
1 +---
2 +'@composio/core': patch
3 +---
4 +
5 +Fix false-positive `initiate()` deprecation warning for custom auth configs (SEC-339 follow-up).
6 +
7 +`composio.connectedAccounts.initiate()` previously emitted a one-time `console.warn` on every redirectable-OAuth response, regardless of whether the auth config was Composio-managed (subject to the 2026-07-03 cutover) or custom (unaffected). The wording 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 logs.
8 +
9 +Apollo already emits the SEC-339 `Deprecation` / `Sunset` / `Link rel="deprecation"` headers (RFC 9745 / RFC 8594) **only** on the retiring branch — managed + redirectable OAuth. The SDK now reads the `Deprecation` header from the response (via `APIPromise.withResponse()`) and gates 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.
10 +
11 +- **Behavior change:** No warning is emitted for `initiate()` calls against custom OAuth auth configs or non-OAuth schemes (API key, bearer, basic). Managed-OAuth callers continue to get exactly one warning per process, now with revised wording that points at the response's `Sunset` header for the precise cutover date.
12 +- **No public API change:** `initiate()` returns the same `ConnectionRequest` shape and respects the same `allowMultiple` guard. `ComposioLegacyConnectedAccountsEndpointRetiredError` continues to surface from the 400 retired-path response.
13 +- **Test scaffolding:** new mock helper `mockApiPromiseWithHeaders()` in `connectedAccounts.test.ts` wraps a value as an `APIPromise`-shaped thenable so the new tests can simulate apollo's header behavior. Pre-existing initiate tests using `mockResolvedValueOnce` continue to pass via the SDK's defensive fallback when `withResponse` is absent on the mock.
14 +
15 +Python SDK gets the matching change in the same release train.
python/composio/core/models/connected_accounts.py
+44 -28
@@ -23,11 +23,6 @@ from .base import Resource
23
24 logger = logging.getLogger(__name__)
25
26 -# Schemes that take the redirectable OAuth path on the legacy
27 -# `POST /api/v3/connected_accounts` endpoint, and so are subject to the
28 -# 2026-05-08 / 2026-07-03 retirement when the auth config is Composio-managed.
29 -_LEGACY_RETIRING_OAUTH_SCHEMES = frozenset({"OAUTH1", "OAUTH2", "DCR_OAUTH"})
30 -
26 # Mirrors TS `ConnectionRequest.ts:terminalErrorStates`. INACTIVE is excluded
27 # on purpose — it can recover to ACTIVE.
28 _TERMINAL_CONNECTION_STATES: t.FrozenSet[str] = frozenset(
@@ -478,13 +473,42 @@ class ConnectedAccounts:
473 if alias is not None:
474 connection["alias"] = alias
475
476 + # Use `with_raw_response.create` so we can read the SEC-339
477 + # `Deprecation` header (RFC 9745) the apollo retiring branch sets —
478 + # that header is emitted only when the auth config is Composio-managed
479 + # AND on a redirectable OAuth scheme, so it's the canonical signal
480 + # that this caller needs to migrate. Custom auth configs and non-OAuth
481 + # schemes never see the header, eliminating the false-positive warning
482 + # that an auth_scheme-only check produced for link()-unaffected callers.
483 + deprecation_header: t.Optional[str] = None
484 try:
482 - response = self._client.connected_accounts.create(
483 - auth_config={"id": auth_config_id},
484 - connection=t.cast(
485 - connected_account_create_params.Connection, connection
486 - ),
485 + ca_client = self._client.connected_accounts
486 + raw_create = getattr(
487 + getattr(ca_client, "with_raw_response", None), "create", None
488 )
489 + if callable(raw_create):
490 + raw = raw_create(
491 + auth_config={"id": auth_config_id},
492 + connection=t.cast(
493 + connected_account_create_params.Connection, connection
494 + ),
495 + )
496 + response = raw.parse() if callable(getattr(raw, "parse", None)) else raw
497 + headers = getattr(raw, "headers", None)
498 + if headers is not None and hasattr(headers, "get"):
499 + value = headers.get("Deprecation") or headers.get("deprecation")
500 + if isinstance(value, str):
501 + deprecation_header = value
502 + else:
503 + # Test mocks may not stub `with_raw_response`. Fall back to
504 + # the parsed-only path; the deprecation gate stays off (no
505 + # header to read).
506 + response = ca_client.create(
507 + auth_config={"id": auth_config_id},
508 + connection=t.cast(
509 + connected_account_create_params.Connection, connection
510 + ),
511 + )
512 except BadRequestError as error:
513 # When the server has flipped this org to the retired path, the
514 # legacy endpoint returns 400 with a stable migration message.
@@ -500,28 +524,20 @@ class ConnectedAccounts:
524 ) from error
525 raise
526
503 - # Warn once per process when a successful initiate() lands on the
504 - # redirectable-OAuth path. We can't tell from the response alone
505 - # whether the auth config is Composio-managed (the field that
506 - # determines whether the cutover applies), so the warning text is
507 - # conditional in wording — custom-OAuth users can ignore it,
508 - # Composio-managed-OAuth users see a clear pointer to link() before
509 - # their org's cutover lands.
527 + # Warn once per process when apollo flags this response as on the
528 + # retiring path. Header presence is a 1:1 signal — custom auth
529 + # configs and non-OAuth schemes get a clean response and stay silent,
530 + # fixing the false-positive that auth_scheme-based detection
531 + # produced.
532 global _legacy_initiate_warning_emitted
511 - response_auth_scheme = getattr(response.connection_data, "auth_scheme", None)
512 - if (
513 - not _legacy_initiate_warning_emitted
514 - and isinstance(response_auth_scheme, str)
515 - and response_auth_scheme in _LEGACY_RETIRING_OAUTH_SCHEMES
516 - ):
533 + if not _legacy_initiate_warning_emitted and deprecation_header:
534 _legacy_initiate_warning_emitted = True
535 warnings.warn(
536 "composio.connected_accounts.initiate() will stop working "
520 - "for Composio-managed OAuth auth configs on 2026-05-08 (new "
521 - "orgs) and 2026-07-03 (all orgs). If this auth config is "
522 - "Composio-managed, switch to "
523 - "composio.connected_accounts.link() before then. Custom "
524 - "auth configs are unaffected. See "
537 + "for this auth config on or before 2026-07-03 (see Sunset "
538 + "header on the response). Switch to "
539 + "composio.connected_accounts.link() — same return shape, "
540 + "same allow_multiple semantics. "
541 "https://docs.composio.dev/docs/changelog/2026/04/24",
542 DeprecationWarning,
543 stacklevel=2,
python/tests/test_connected_accounts.py
+130 -4
@@ -1,5 +1,6 @@
1 import logging
2 import time
3 +import warnings
4 from unittest.mock import Mock, patch
5
6 import pytest
@@ -13,6 +14,22 @@ from composio.core.models.connected_accounts import (
14 )
15
16
17 +def _set_initiate_response(mock_client, body, headers=None):
18 + """SEC-339: route an `initiate()` mock response through the
19 + ``with_raw_response.create`` surface that the SDK consumes for
20 + deprecation-header gating.
21 +
22 + ``headers`` defaults to ``None`` (no Deprecation header → no warning,
23 + matching custom-auth-config / non-OAuth-scheme behavior). Pass
24 + ``{"Deprecation": "@..."}`` to simulate the apollo retiring branch.
25 + """
26 + raw = Mock()
27 + raw.parse.return_value = body
28 + raw.headers = headers or {}
29 + mock_client.connected_accounts.with_raw_response.create.return_value = raw
30 + return raw
31 +
32 +
33 class TestAuthScheme:
34 def test_oauth2_with_access_token_sets_active_status(self):
35 scheme = AuthScheme()
@@ -322,7 +339,7 @@ class TestConnectedAccounts:
339 mock_response.id = "conn-123"
340 mock_response.connection_data.val.status = "PENDING"
341 mock_response.connection_data.val.redirect_url = "https://redirect"
325 - mock_client.connected_accounts.create.return_value = mock_response
342 + _set_initiate_response(mock_client, mock_response)
343
344 connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")
345
@@ -342,7 +359,7 @@ class TestConnectedAccounts:
359 mock_response.id = "conn-123"
360 mock_response.connection_data.val.status = "PENDING"
361 mock_response.connection_data.val.redirect_url = "https://redirect"
345 - mock_client.connected_accounts.create.return_value = mock_response
362 + _set_initiate_response(mock_client, mock_response)
363
364 config = {
365 "auth_scheme": "API_KEY",
@@ -361,7 +378,9 @@ class TestConnectedAccounts:
378 mock_client.connected_accounts.list.assert_called_once_with(
379 user_ids=["user-1"], auth_config_ids=["auth-1"], statuses=["ACTIVE"]
380 )
364 - call_kwargs = mock_client.connected_accounts.create.call_args.kwargs
381 + call_kwargs = (
382 + mock_client.connected_accounts.with_raw_response.create.call_args.kwargs
383 + )
384 assert call_kwargs["auth_config"] == {"id": "auth-1"}
385 assert call_kwargs["connection"]["user_id"] == "user-1"
386 assert call_kwargs["connection"]["callback_url"] == "https://cb"
@@ -473,7 +492,7 @@ class TestConnectedAccounts:
492 mock_response.id = "conn-active"
493 mock_response.connection_data.val.status = "ACTIVE"
494 mock_response.connection_data.val.redirect_url = None
476 - mock_client.connected_accounts.create.return_value = mock_response
495 + _set_initiate_response(mock_client, mock_response)
496
497 scheme = AuthScheme()
498 config = scheme.oauth2(
@@ -504,3 +523,110 @@ class TestConnectedAccounts:
523 mock_from_id.assert_called_once_with(id="conn-123", client=mock_client)
524 mock_request.wait_for_connection.assert_called_once_with(timeout=42.0)
525 assert result == "connected"
526 +
527 +
528 +# SEC-339: initiate() must gate its DeprecationWarning on the response
529 +# `Deprecation` HTTP header (RFC 9745) that apollo emits only on the
530 +# retiring branch (Composio-managed + redirectable OAuth). These tests pin
531 +# that contract so the previous false-positive behavior — warning purely
532 +# off auth_scheme, which over-fired for custom auth configs — can't come
533 +# back. See https://docs.composio.dev/docs/changelog/2026/04/24
534 +class TestInitiateDeprecationHeaderGate:
535 + @pytest.fixture
536 + def mock_client(self):
537 + client = Mock()
538 + client.connected_accounts.list = Mock()
539 + return client
540 +
541 + @pytest.fixture(autouse=True)
542 + def _reset_warning_flag(self):
543 + """Reset the module-level one-time warning guard before each test
544 + so warning emission is deterministic regardless of test order."""
545 + import composio.core.models.connected_accounts as ca_mod
546 +
547 + ca_mod._legacy_initiate_warning_emitted = False
548 + yield
549 + ca_mod._legacy_initiate_warning_emitted = False
550 +
551 + @staticmethod
552 + def _no_existing_accounts(mock_client):
553 + empty = Mock()
554 + empty.items = []
555 + mock_client.connected_accounts.list.return_value = empty
556 +
557 + @staticmethod
558 + def _make_response():
559 + body = Mock()
560 + body.id = "conn-dep"
561 + body.connection_data.val.status = "INITIATED"
562 + body.connection_data.val.redirect_url = "https://redirect"
563 + return body
564 +
565 + def test_warns_once_when_response_carries_deprecation_header(self, mock_client):
566 + """Managed + redirectable-OAuth path: apollo sets `Deprecation`,
567 + SDK emits a `DeprecationWarning` pointing callers at link()."""
568 + self._no_existing_accounts(mock_client)
569 + body = self._make_response()
570 + _set_initiate_response(
571 + mock_client,
572 + body,
573 + headers={
574 + "Deprecation": "@1776988800",
575 + "Sunset": "Fri, 08 May 2026 00:00:00 GMT",
576 + "Link": (
577 + "<https://docs.composio.dev/docs/changelog/2026/04/24>; "
578 + 'rel="deprecation"'
579 + ),
580 + },
581 + )
582 +
583 + connected_accounts = ConnectedAccounts(client=mock_client)
584 + with warnings.catch_warnings(record=True) as caught:
585 + warnings.simplefilter("always")
586 + req = connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")
587 +
588 + assert isinstance(req, ConnectionRequest)
589 + deprecations = [w for w in caught if issubclass(w.category, DeprecationWarning)]
590 + assert len(deprecations) == 1
591 + message = str(deprecations[0].message)
592 + assert "composio.connected_accounts.link()" in message
593 + assert "2026-07-03" in message
594 +
595 + def test_does_not_warn_when_response_has_no_deprecation_header(self, mock_client):
596 + """Custom auth config / non-OAuth scheme: apollo returns a clean
597 + response, SDK must stay silent. Regression for the prior
598 + auth_scheme-only check that over-fired here."""
599 + self._no_existing_accounts(mock_client)
600 + _set_initiate_response(mock_client, self._make_response(), headers={})
601 +
602 + connected_accounts = ConnectedAccounts(client=mock_client)
603 + with warnings.catch_warnings(record=True) as caught:
604 + warnings.simplefilter("always")
605 + connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")
606 +
607 + deprecations = [w for w in caught if issubclass(w.category, DeprecationWarning)]
608 + assert deprecations == []
609 +
610 + def test_warns_at_most_once_per_process_across_calls(self, mock_client):
611 + """The one-time guard must hold across multiple calls in the same
612 + process even when each response carries the Deprecation header."""
613 + self._no_existing_accounts(mock_client)
614 + # Same headers for both calls; helper rewires the same return on
615 + # each invocation, so both calls see the Deprecation header.
616 + _set_initiate_response(
617 + mock_client,
618 + self._make_response(),
619 + headers={"Deprecation": "@1776988800"},
620 + )
621 +
622 + connected_accounts = ConnectedAccounts(client=mock_client)
623 + with warnings.catch_warnings(record=True) as caught:
624 + warnings.simplefilter("always")
625 + connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")
626 + empty = Mock()
627 + empty.items = []
628 + mock_client.connected_accounts.list.return_value = empty
629 + connected_accounts.initiate(user_id="user-1", auth_config_id="auth-1")
630 +
631 + deprecations = [w for w in caught if issubclass(w.category, DeprecationWarning)]
632 + assert len(deprecations) == 1
ts/packages/core/src/models/ConnectedAccounts.ts
+36 -23
@@ -7,6 +7,7 @@
7 */
8 import ComposioClient, { BadRequestError } from '@composio/client';
9 import {
10 + ConnectedAccountCreateResponse,
11 ConnectedAccountDeleteResponse,
12 ConnectedAccountRefreshParams,
13 ConnectedAccountRefreshResponse,
@@ -45,11 +46,6 @@ import {
46 import logger from '../utils/logger';
47 import { ConnectionData } from '../types/connectedAccountAuthStates.types';
48
48 -// Schemes that take the redirectable OAuth path on the legacy
49 -// `POST /api/v3/connected_accounts` endpoint, and so are subject to the
50 -// 2026-05-08 / 2026-07-03 retirement when the auth config is Composio-managed.
51 -const LEGACY_RETIRING_OAUTH_SCHEMES = new Set(['OAUTH1', 'OAUTH2', 'DCR_OAUTH']);
52 -
49 // One-time-per-process guard so long-running services don't spam the deprecation
50 // warning on every initiate() call.
51 let _legacyInitiateWarningEmitted = false;
@@ -232,9 +228,34 @@ export class ConnectedAccounts {
228 },
229 };
230
235 - let response;
231 + let response: ConnectedAccountCreateResponse;
232 + let httpResponse: Response | undefined;
233 try {
237 - response = await this.client.connectedAccounts.create(createParams);
234 + // Chain `.withResponse()` so we can read the SEC-339 `Deprecation`
235 + // header (RFC 9745) the apollo retiring branch sets — that header is
236 + // emitted only when the auth config is Composio-managed AND on a
237 + // redirectable OAuth scheme, so it's the canonical signal that this
238 + // caller needs to migrate. Custom auth configs and non-OAuth schemes
239 + // never see the header, eliminating the false-positive warning that
240 + // an `auth_scheme`-only check produced for `link()`-unaffected callers.
241 + const apiCall = this.client.connectedAccounts.create(createParams);
242 + if (typeof (apiCall as { withResponse?: unknown }).withResponse === 'function') {
243 + const resolved = await (
244 + apiCall as unknown as {
245 + withResponse: () => Promise<{
246 + data: ConnectedAccountCreateResponse;
247 + response: Response;
248 + }>;
249 + }
250 + ).withResponse();
251 + response = resolved.data;
252 + httpResponse = resolved.response;
253 + } else {
254 + // Test mocks may return a plain Promise without `withResponse`.
255 + // Fall back to a naked await; the deprecation gate below stays
256 + // off in that case (no header to read).
257 + response = await apiCall;
258 + }
259 } catch (error) {
260 // When the server has flipped this org to the retired path, the legacy
261 // endpoint returns 400 with a stable migration message. Surface it as
@@ -253,25 +274,17 @@ export class ConnectedAccounts {
274 throw error;
275 }
276
256 - // Warn once per process when a successful initiate() lands on the
257 - // redirectable-OAuth path. We can't tell from the response alone whether
258 - // the auth config is Composio-managed (the field that determines whether
259 - // the cutover applies), so the warning text is conditional in wording —
260 - // custom-OAuth users can ignore it, Composio-managed-OAuth users see a
261 - // clear pointer to link() before their org's cutover lands.
262 - const responseAuthScheme = response.connectionData?.authScheme;
263 - if (
264 - !_legacyInitiateWarningEmitted &&
265 - typeof responseAuthScheme === 'string' &&
266 - LEGACY_RETIRING_OAUTH_SCHEMES.has(responseAuthScheme)
267 - ) {
277 + // Warn once per process when apollo flags this response as on the
278 + // retiring path. Header presence is a 1:1 signal — custom auth configs
279 + // and non-OAuth schemes get a clean response and stay silent, fixing
280 + // the false-positive that auth_scheme-based detection produced.
281 + if (!_legacyInitiateWarningEmitted && httpResponse?.headers.get('Deprecation')) {
282 _legacyInitiateWarningEmitted = true;
283 logger.warn(
284 '[Deprecation] composio.connectedAccounts.initiate() will stop ' +
271 - 'working for Composio-managed OAuth auth configs on 2026-05-08 ' +
272 - '(new orgs) and 2026-07-03 (all orgs). If this auth config is ' +
273 - 'Composio-managed, switch to composio.connectedAccounts.link() ' +
274 - 'before then. Custom auth configs are unaffected. See ' +
285 + 'working for this auth config on or before 2026-07-03 (see Sunset ' +
286 + 'header on the response). Switch to composio.connectedAccounts.link() — ' +
287 + 'same return shape, same allowMultiple semantics. ' +
288 'https://docs.composio.dev/docs/changelog/2026/04/24'
289 );
290 }
ts/packages/core/test/connectedAccounts/connectedAccounts.test.ts
+114
@@ -498,6 +498,120 @@ describe('ConnectedAccounts', () => {
498 });
499 });
500
501 + // SEC-339: initiate() must gate its deprecation warning on the response
502 + // `Deprecation` HTTP header (RFC 9745) that apollo emits only on the
503 + // retiring branch (Composio-managed + redirectable OAuth). These tests pin
504 + // that contract so the previous false-positive behavior — warning purely
505 + // off auth_scheme, which over-fired for custom auth configs — can't come
506 + // back. See https://docs.composio.dev/docs/changelog/2026/04/24
507 + describe('initiate deprecation header gate', () => {
508 + /** Wrap a value as an APIPromise-shaped thenable that also exposes
509 + * `.withResponse()` returning the value plus a synthesised Response
510 + * carrying the given headers. Mirrors the @composio/client APIPromise
511 + * surface that the SDK now consumes for header-aware deprecation. */
512 + function mockApiPromiseWithHeaders<T>(
513 + data: T,
514 + headers: Record<string, string> = {}
515 + ): Promise<T> & {
516 + withResponse: () => Promise<{ data: T; response: Response }>;
517 + } {
518 + const response = new Response(null, { headers: new Headers(headers) });
519 + const promise = Promise.resolve(data) as Promise<T> & {
520 + withResponse: () => Promise<{ data: T; response: Response }>;
521 + };
522 + promise.withResponse = () => Promise.resolve({ data, response });
523 + return promise;
524 + }
525 +
526 + const userId = 'user_dep';
527 + const authConfigId = 'auth_config_dep';
528 + const baseResponse = {
529 + id: 'conn_dep',
530 + connectionData: {
531 + val: {
532 + authScheme: AuthSchemeTypes.OAUTH2,
533 + status: 'INITIALIZING',
534 + redirectUrl: 'https://auth.example.com/connect',
535 + },
536 + },
537 + };
538 +
539 + /** Re-import the model with a fresh module-level
540 + * `_legacyInitiateWarningEmitted` so each test starts unwarned. */
541 + async function freshConnectedAccounts() {
542 + vi.resetModules();
543 + const { ConnectedAccounts: Fresh } = await import('../../src/models/ConnectedAccounts');
544 + const fresh = new Fresh(extendedMockClient as unknown as ComposioClient);
545 + const loggerMod = await import('../../src/utils/logger');
546 + const warnSpy = vi.spyOn(loggerMod.default, 'warn').mockImplementation(() => {});
547 + return { connectedAccounts: fresh, warnSpy };
548 + }
549 +
550 + it('warns once when response carries a Deprecation header (managed + OAuth retiring path)', async () => {
551 + const { connectedAccounts: fresh, warnSpy } = await freshConnectedAccounts();
552 + extendedMockClient.connectedAccounts.list.mockResolvedValueOnce({
553 + items: [],
554 + next_cursor: null,
555 + total_pages: 1,
556 + });
557 + extendedMockClient.connectedAccounts.create.mockReturnValueOnce(
558 + mockApiPromiseWithHeaders(baseResponse, {
559 + Deprecation: '@1776988800',
560 + Sunset: 'Fri, 08 May 2026 00:00:00 GMT',
561 + Link: '<https://docs.composio.dev/docs/changelog/2026/04/24>; rel="deprecation"',
562 + })
563 + );
564 +
565 + const req = await fresh.initiate(userId, authConfigId);
566 +
567 + expect(req).toHaveProperty('id', 'conn_dep');
568 + expect(warnSpy).toHaveBeenCalledTimes(1);
569 + expect(warnSpy.mock.calls[0]![0]).toMatch(/composio\.connectedAccounts\.link\(\)/);
570 + expect(warnSpy.mock.calls[0]![0]).toMatch(/2026-07-03/);
571 + });
572 +
573 + it('does NOT warn when response has no Deprecation header (custom auth config)', async () => {
574 + // Regression test: prior auth_scheme-only check warned for any
575 + // OAUTH2 response, including custom configs that are not subject
576 + // to the cutover. Header absence is the canonical "you're fine"
577 + // signal from apollo.
578 + const { connectedAccounts: fresh, warnSpy } = await freshConnectedAccounts();
579 + extendedMockClient.connectedAccounts.list.mockResolvedValueOnce({
580 + items: [],
581 + next_cursor: null,
582 + total_pages: 1,
583 + });
584 + extendedMockClient.connectedAccounts.create.mockReturnValueOnce(
585 + mockApiPromiseWithHeaders(baseResponse /* no Deprecation header */)
586 + );
587 +
588 + const req = await fresh.initiate(userId, authConfigId);
589 +
590 + expect(req).toHaveProperty('id', 'conn_dep');
591 + expect(warnSpy).not.toHaveBeenCalled();
592 + });
593 +
594 + it('warns at most once per process even across multiple managed-OAuth calls', async () => {
595 + const { connectedAccounts: fresh, warnSpy } = await freshConnectedAccounts();
596 + // Two consecutive managed-OAuth calls. Both responses carry the
597 + // Deprecation header, but the module-level guard should let only
598 + // the first one through.
599 + for (let i = 0; i < 2; i++) {
600 + extendedMockClient.connectedAccounts.list.mockResolvedValueOnce({
601 + items: [],
602 + next_cursor: null,
603 + total_pages: 1,
604 + });
605 + extendedMockClient.connectedAccounts.create.mockReturnValueOnce(
606 + mockApiPromiseWithHeaders(baseResponse, { Deprecation: '@1776988800' })
607 + );
608 + await fresh.initiate(userId, authConfigId);
609 + }
610 +
611 + expect(warnSpy).toHaveBeenCalledTimes(1);
612 + });
613 + });
614 +
615 describe('get', () => {
616 it('should retrieve a connected account by nanoid and transform the response', async () => {
617 const nanoid = 'conn_123';