Skip to content

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(cli): apply unknown-status guard to connections list/remove commands

jkomyno0c9cb82fed0a
diff --git a/ts/packages/cli/src/commands/connections/commands/connections.list.cmd.ts b/ts/packages/cli/src/commands/connections/commands/connections.list.cmd.ts
index a2a95abf9..50f41990d 100644
--- a/ts/packages/cli/src/commands/connections/commands/connections.list.cmd.ts
+++ b/ts/packages/cli/src/commands/connections/commands/connections.list.cmd.ts
@@ -73,7 +73,22 @@ export const connectionsCmd$List = Command.make('list', { toolkit }, ({ toolkit
limit: 1000,
})
);
- const result = yield* Schema.decodeUnknown(ConnectedAccountListResponse)(rawResult);
+ // Same forward-compat guard as `connected-accounts.list.cmd.ts`: the
+ // closed `Schema.Literal(...)` for `status` would brick this command
+ // for the entire user base when Apollo adds a new enum value.
+ const result = yield* Schema.decodeUnknown(ConnectedAccountListResponse)(rawResult).pipe(
+ Effect.catchTag('ParseError', error =>
+ Effect.gen(function* () {
+ yield* ui.log.warn(
+ `Server returned a connection field this CLI does not recognize ` +
+ `(likely a newly-added status). Run "composio upgrade" to pick up ` +
+ `the latest schema. Continuing with raw response.\n\n` +
+ `Decode error: ${error.message}`
+ );
+ return rawResult as ConnectedAccountListResponse;
+ })
+ )
+ );
yield* ui.output(formatConnectionsJson(result.items), { force: true });
})
diff --git a/ts/packages/cli/src/commands/connections/commands/connections.remove.cmd.ts b/ts/packages/cli/src/commands/connections/commands/connections.remove.cmd.ts
index ab0893720..aa5a96c70 100644
--- a/ts/packages/cli/src/commands/connections/commands/connections.remove.cmd.ts
+++ b/ts/packages/cli/src/commands/connections/commands/connections.remove.cmd.ts
@@ -109,7 +109,22 @@ export const connectionsCmd$Remove = Command.make('remove', { account }, ({ acco
})
)
);
- const result = yield* Schema.decodeUnknown(ConnectedAccountListResponse)(rawResult);
+ // Same forward-compat guard as `connected-accounts.list.cmd.ts`: the
+ // closed `Schema.Literal(...)` for `status` would brick this command
+ // for the entire user base when Apollo adds a new enum value.
+ const result = yield* Schema.decodeUnknown(ConnectedAccountListResponse)(rawResult).pipe(
+ Effect.catchTag('ParseError', error =>
+ Effect.gen(function* () {
+ yield* ui.log.warn(
+ `Server returned a connection field this CLI does not recognize ` +
+ `(likely a newly-added status). Run "composio upgrade" to pick up ` +
+ `the latest schema. Continuing with raw response.\n\n` +
+ `Decode error: ${error.message}`
+ );
+ return rawResult as ConnectedAccountListResponse;
+ })
+ )
+ );
const resolved = resolveAccount({ accounts: result.items, selector: account });
if ('error' in resolved) {