@devries-cameron20 / composio-1 / commits / c9f5cb348
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.

feat(sdk-ts): typed ComposioLegacyConnectedAccountsEndpointRetiredError

Add a dedicated error class returned by initiate() once the legacy POST /api/v3/connected_accounts path starts rejecting Composio-managed OAuth requests. Carries the migration message and a possibleFixes block pointing at link() and the migration guide. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

Composio committed Apr 25, 2026 at 18:12 UTC c9f5cb348d126f1f188ed7ef8f0571c434461ab8
1 file changed +33
ts/packages/core/src/errors/ConnectedAccountsErrors.ts
+33
@@ -4,6 +4,7 @@ export const ConnectedAccountErrorCodes = {
4 CONNECTED_ACCOUNT_NOT_FOUND: 'CONNECTED_ACCOUNT_NOT_FOUND',
5 MULTIPLE_CONNECTED_ACCOUNTS: 'MULTIPLE_CONNECTED_ACCOUNTS',
6 FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK: 'FAILED_TO_CREATE_CONNECTED_ACCOUNT_LINK',
7 + LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED: 'LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED',
8 } as const;
9
10 export class ComposioConnectedAccountNotFoundError extends ComposioError {
@@ -51,3 +52,35 @@ export class ComposioFailedToCreateConnectedAccountLink extends ComposioError {
52 this.name = 'ComposioFailedToCreateConnectedAccountLink';
53 }
54 }
55 +
56 +/**
57 + * Thrown by `composio.connectedAccounts.initiate()` when the legacy
58 + * `POST /api/v3/connected_accounts` endpoint rejects a Composio-managed
59 + * OAuth (OAuth1, OAuth2, DCR_OAUTH) auth-config request.
60 + *
61 + * The retiring path is being phased out — new orgs from 2026-05-08 and
62 + * all remaining orgs from 2026-07-03. Migrate the call to
63 + * `composio.connectedAccounts.link()`, which works for every redirectable
64 + * scheme regardless of whether the auth config is Composio-managed or
65 + * custom.
66 + *
67 + * See: https://docs.composio.dev/docs/changelog/2026/04/24
68 + */
69 +export class ComposioLegacyConnectedAccountsEndpointRetiredError extends ComposioError {
70 + constructor(
71 + message: string = 'POST /api/v3/connected_accounts is no longer supported for Composio-managed OAuth auth configs. Use composio.connectedAccounts.link() instead.',
72 + options: Omit<ComposioErrorOptions, 'code' | 'statusCode'> = {}
73 + ) {
74 + super(message, {
75 + ...options,
76 + code: ConnectedAccountErrorCodes.LEGACY_CONNECTED_ACCOUNTS_ENDPOINT_RETIRED,
77 + statusCode: 400,
78 + possibleFixes: options.possibleFixes || [
79 + 'Replace `composio.connectedAccounts.initiate(userId, authConfigId, options)` with `composio.connectedAccounts.link(userId, authConfigId, options)`. The return shape (id, redirectUrl, waitForConnection()) is the same.',
80 + 'If you relied on the `allowMultiple` guard in initiate(), pre-check existing active connections with `composio.connectedAccounts.list({ userIds, authConfigIds, statuses: [ConnectedAccountStatuses.ACTIVE] })` before calling link().',
81 + 'Migration guide: https://docs.composio.dev/docs/changelog/2026/04/24',
82 + ],
83 + });
84 + this.name = 'ComposioLegacyConnectedAccountsEndpointRetiredError';
85 + }
86 +}