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): report unknown listen slugs when the inferred toolkit has an account
jkomyno committed
Sep 15, 2026 at 12:16 UTC
f3bfa0670491633260fa6becf61420d1020a4002
3 files changed
+94
-8
ts/packages/cli/src/commands/listen.cmd.ts
+11
-5
@@ -153,13 +153,14 @@ const assertSupportedListenParams = (params: {
153
/**
154
* Fails with an `unknown_trigger` error when `slug` is not a known trigger type.
155
*
156
- * Only called once no active connected account matched, so a mistyped slug is reported as such
157
- * instead of as a missing connection for the toolkit inferred from its prefix.
156
+ * Called when no active connected account matched, and when creating the temporary trigger fails,
157
+ * so a mistyped slug is reported as such instead of as a missing connection or a generic creation
158
+ * failure. Neither call site is on the happy path, which makes no additional request.
159
*/
160
const assertTriggerTypeExists = (params: {
161
client: RawComposioClient;
162
slug: string;
162
- toolkitSlug: string;
163
+ toolkitSlug?: string;
164
}) =>
165
Effect.gen(function* () {
166
const lookup = yield* Effect.tryPromise({
@@ -177,7 +178,7 @@ const assertTriggerTypeExists = (params: {
178
});
179
}
180
// A found trigger type, or any failure other than 404, is inconclusive here: fall through to
180
- // the connected-account error.
181
+ // the caller's own error.
182
});
183
184
const resolveConnectedAccountIdForTrigger = (params: {
@@ -548,7 +549,12 @@ export const listenCmd = Command.make(
549
slug,
550
cause,
551
}),
551
- }),
552
+ }).pipe(
553
+ // An active account for the inferred toolkit skips the lookup in
554
+ // resolveConnectedAccountIdForTrigger, so a mistyped slug with a valid toolkit prefix
555
+ // only surfaces here.
556
+ Effect.tapError(() => assertTriggerTypeExists({ client, slug }))
557
+ ),
558
createdTrigger =>
559
Effect.gen(function* () {
560
yield* emitStreamLine(`listening for events ${slug} (tail at ${streamFilePath})`, ui);
ts/packages/cli/test/__utils__/services/test-layer.ts
+18
-3
@@ -141,6 +141,11 @@ export interface TestLiveInput {
141
*/
142
triggersData?: {
143
items?: TriggerInstanceItem[];
144
+ /**
145
+ * Make `triggerInstances.upsert` reject slugs missing from `toolkitsData.triggerTypes`,
146
+ * as the API does for an unknown trigger type.
147
+ */
148
+ rejectUnknownTriggerSlugs?: boolean;
149
};
150
151
/**
@@ -1122,9 +1127,19 @@ export const TestLayer = (input?: TestLiveInput) =>
1127
connected_account_id?: string;
1128
trigger_config?: Record<string, unknown>;
1129
}
1125
- ) => ({
1126
- trigger_id: `trg_${triggerSlug.toLowerCase()}_${params?.connected_account_id ?? 'new'}`,
1127
- }),
1130
+ ) => {
1131
+ if (
1132
+ input?.triggersData?.rejectUnknownTriggerSlugs &&
1133
+ !toolkitsData.triggerTypes.some(
1134
+ trigger => trigger.slug.toUpperCase() === triggerSlug.toUpperCase()
1135
+ )
1136
+ ) {
1137
+ throw new Error(`Trigger type "${triggerSlug}" not found`);
1138
+ }
1139
+ return {
1140
+ trigger_id: `trg_${triggerSlug.toLowerCase()}_${params?.connected_account_id ?? 'new'}`,
1141
+ };
1142
+ },
1143
manage: {
1144
update: async (triggerId: string, params: { status: 'enable' | 'disable' }) => ({
1145
trigger_id: triggerId,
ts/packages/cli/test/src/commands/listen.cmd.test.ts
+65
@@ -259,4 +259,69 @@ describe('CLI: composio listen', () => {
259
})
260
);
261
});
262
+
263
+ layer(
264
+ TestLive({
265
+ baseConfigProvider: testConfigProvider,
266
+ fixture: 'global-test-user-id',
267
+ connectedAccountsData: {
268
+ items: [
269
+ {
270
+ id: 'con_gmail_test',
271
+ status: 'ACTIVE',
272
+ status_reason: null,
273
+ is_disabled: false,
274
+ user_id: 'consumer-user-org_test',
275
+ toolkit: {
276
+ slug: 'gmail',
277
+ },
278
+ auth_config: {
279
+ id: 'auth_gmail_test',
280
+ auth_scheme: 'OAUTH2',
281
+ is_composio_managed: true,
282
+ is_disabled: false,
283
+ },
284
+ created_at: '2026-04-06T17:59:00.000Z',
285
+ updated_at: '2026-04-06T18:00:00.000Z',
286
+ test_request_endpoint: '',
287
+ },
288
+ ],
289
+ },
290
+ toolkitsData: {
291
+ triggerTypes: [
292
+ {
293
+ slug: 'GMAIL_NEW_GMAIL_MESSAGE',
294
+ name: 'New Gmail Message',
295
+ description: 'Fires when a new email arrives.',
296
+ instructions: '',
297
+ type: 'poll',
298
+ config: {},
299
+ payload: {},
300
+ toolkit: { name: 'Gmail', slug: 'gmail' },
301
+ },
302
+ ],
303
+ },
304
+ triggersData: { rejectUnknownTriggerSlugs: true },
305
+ })
306
+ )('[Given] an active account for the inferred toolkit', it => {
307
+ it.effect('[Then] reports an unknown trigger slug instead of a creation failure', () =>
308
+ Effect.gen(function* () {
309
+ yield* enableListen;
310
+ const exit = yield* Effect.exit(cli(['listen', 'GMAIL_NEW_GMAIL_MESAGE']));
311
+
312
+ expect(Exit.isFailure(exit)).toBe(true);
313
+ if (Exit.isFailure(exit)) {
314
+ const failure = Cause.squash(exit.cause);
315
+ expect(failure).toBeInstanceOf(ListenCommandError);
316
+ if (failure instanceof ListenCommandError) {
317
+ expect(failure).toMatchObject({
318
+ reason: 'unknown_trigger',
319
+ slug: 'GMAIL_NEW_GMAIL_MESAGE',
320
+ });
321
+ expect(failure.message).toContain('Unknown trigger slug "GMAIL_NEW_GMAIL_MESAGE"');
322
+ }
323
+ }
324
+ })
325
+ );
326
+ });
327
});