@devries-cameron20 / composio-1 / commits / 55dee9f2b
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): accept REVOKED in nested connection-data schema

Codex round 2 caught that the top-level `ConnectedAccountStatusSchema` already accepted REVOKED, but the nested `state.val.status` validation went through `ConnectionStatuses` in `connectedAccountAuthStates.types.ts` which still only knew the prior 6 values. As a result: - `transformConnectedAccountResponse` would silently drop the `state` of any REVOKED account (the discriminated union has no REVOKED variant). - `webhookEvents.types.ts` (which uses `z.nativeEnum(ConnectionStatuses)` for `data.status`) would reject any webhook payload whose top-level account status is REVOKED. Fix: - Add REVOKED to the `ConnectionStatuses` enum (transitively fixes the webhook schema via `nativeEnum`). - Add `Oauth2RevokedConnectionDataSchema` mirroring the Apollo-side schema at `connectionDataScheme.ts` (shape = INITIATING + literal REVOKED status + optional `revoked_at` timestamp), wire it into the `Oauth2ConnectionDataSchema` discriminated union, and export the inferred type. Apollo's PR 9550 only added a REVOKED variant to the OAuth2 scheme; other auth schemes (ApiKey / Basic / Bearer / etc.) do not produce REVOKED at runtime so they don't need a new variant.

Zen Agent committed May 5, 2026 at 04:58 UTC 55dee9f2bdff58176406dfca9c10ded517d89b9b
1 file changed +12
ts/packages/core/src/types/connectedAccountAuthStates.types.ts
+12
@@ -8,6 +8,7 @@ export const ConnectionStatuses = {
8 FAILED: 'FAILED',
9 EXPIRED: 'EXPIRED',
10 INACTIVE: 'INACTIVE',
11 + REVOKED: 'REVOKED',
12 } as const;
13 export type ConnectionStatusEnum = (typeof ConnectionStatuses)[keyof typeof ConnectionStatuses];
14
@@ -144,6 +145,15 @@ export const Oauth2InactiveConnectionDataSchema = Oauth2InitiatingConnectionData
145 .describe('for slack user scopes'),
146 }).catchall(z.unknown());
147
148 +// Mirrors `Oauth2RevokedConnectionDataSchema` on the Apollo side
149 +// (`apps/apollo/src/lib/connected_accounts/schemes/connectionDataScheme.ts`):
150 +// shape matches the INITIATING schema with a status literal, plus an
151 +// optional `revoked_at` timestamp.
152 +export const Oauth2RevokedConnectionDataSchema = Oauth2InitiatingConnectionDataSchema.extend({
153 + status: z.literal(ConnectionStatuses.REVOKED),
154 + revoked_at: z.string().optional(),
155 +}).catchall(z.unknown());
156 +
157 export const Oauth2ConnectionDataSchema = z.discriminatedUnion('status', [
158 Oauth2InitiatingConnectionDataSchema,
159 Oauth2InitiatedConnectionDataSchema,
@@ -151,6 +161,7 @@ export const Oauth2ConnectionDataSchema = z.discriminatedUnion('status', [
161 Oauth2FailedConnectionDataSchema,
162 Oauth2ExpiredConnectionDataSchema,
163 Oauth2InactiveConnectionDataSchema,
164 + Oauth2RevokedConnectionDataSchema,
165 ]);
166
167 export const CustomOauth2ConnectionDataSchema = Oauth2ActiveConnectionDataSchema.omit({
@@ -163,6 +174,7 @@ export type Oauth2ActiveConnectionData = z.infer<typeof Oauth2ActiveConnectionDa
174 export type Oauth2FailedConnectionData = z.infer<typeof Oauth2FailedConnectionDataSchema>;
175 export type Oauth2ExpiredConnectionData = z.infer<typeof Oauth2ExpiredConnectionDataSchema>;
176 export type Oauth2InactiveConnectionData = z.infer<typeof Oauth2InactiveConnectionDataSchema>;
177 +export type Oauth2RevokedConnectionData = z.infer<typeof Oauth2RevokedConnectionDataSchema>;
178 export type Oauth2ConnectionData = z.infer<typeof Oauth2ConnectionDataSchema>;
179 export type CustomOauth2ConnectionData = z.infer<typeof CustomOauth2ConnectionDataSchema>;
180