@devries-cameron20 / composio-1 / commits / c3623cb89
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(cli): nest custom credentials under auth_config.credentials in auth-configs create (#4063)

## Summary The `composio dev auth-configs create` command fails when custom OAuth credentials are spread at the top level of `auth_config`. The API expects those values under `auth_config.credentials`. Fixes #4058 ## Changes - Nests custom credentials under `auth_config.credentials`. - Merges parsed `--scopes` into the same credentials object. - Preserves `credentials: undefined` when neither credentials nor scopes are supplied. - Captures the typed repository request in the CLI test layer and asserts the exact custom OAuth payload. - Records the user-visible fix in the CLI changelog. - Merges the current `next` branch without conflicts. ## Verification - Reproduced on the old implementation: 1 of 8 focused tests failed because `client_id` remained at `auth_config.client_id`. - Verified the fix: 8 of 8 focused auth-config create tests passed. - Full CLI package suite: 120 test files passed; 1,188 tests passed; 1 skipped. - `pnpm typecheck`: 14 tasks passed across the 19 TypeScript packages in scope. - `pnpm run lint:packages`: passed with existing warnings only. - Prettier check on all four changed files: passed. The fresh-worktree CLI suite currently needs a temporary local Vitest alias for the pre-existing `#ssrf_guard` resolver drift. That alias was used only to run the suite and is not part of this PR. ## Release notes `@composio/cli` is excluded from Changesets, so this PR updates `ts/packages/cli/CHANGELOG.md` directly. --------- Co-authored-by: jkomyno <alberto@composio.dev>

Azhar committed Aug 13, 2026 at 02:48 UTC c3623cb898258abff5fd14f0799011e4fd96e284
4 files changed +77 -6
ts/packages/cli/CHANGELOG.md
+5
@@ -2,6 +2,11 @@
2
3 ## Unreleased
4
5 +### Patch Changes
6 +
7 +- `composio dev auth-configs create` now sends custom OAuth credentials and scopes
8 + in the API's expected shape instead of failing validation.
9 +
10 ## 0.3.3
11
12 ### Patch Changes
ts/packages/cli/src/commands/auth-configs/commands/auth-configs.create.cmd.ts
+8 -3
@@ -87,15 +87,20 @@ export const authConfigsCmd$Create = Command.make(
87 let params: AuthConfigCreateParams;
88
89 if (Option.isSome(authScheme)) {
90 - // Custom auth mode — spread user-provided credentials FIRST so explicit fields always win
90 + // Custom credentials must be nested under `credentials` for the API to accept them.
91 params = {
92 toolkit: { slug: toolkit },
93 auth_config: {
94 - ...parsedCustomCredentials,
94 type: 'use_custom_auth' as const,
95 authScheme: authScheme.value as AuthConfigCreateParams.UnionMember1['authScheme'],
96 name: nameValue,
98 - credentials: scopesList ? { scopes: scopesList } : undefined,
97 + credentials:
98 + parsedCustomCredentials || scopesList
99 + ? {
100 + ...(parsedCustomCredentials ?? {}),
101 + ...(scopesList ? { scopes: scopesList } : {}),
102 + }
103 + : undefined,
104 },
105 };
106 } else {
ts/packages/cli/test/__utils__/services/test-layer.ts
+7 -3
@@ -1,6 +1,7 @@
1 import path from 'node:path';
2 import * as tempy from 'tempy';
3 import { Composio as RawComposioClient } from '@composio/client';
4 +import type { AuthConfigCreateParams } from '@composio/client/resources/auth-configs';
5 import { CliApp, CliConfig } from '@effect/cli';
6 import { Command, FetchHttpClient, FileSystem, Path } from '@effect/platform';
7 import { BunFileSystem, BunContext, BunPath } from '@effect/platform-bun';
@@ -114,6 +115,7 @@ toolkitsData?: {
115 authConfigsData?: {
116 items?: AuthConfigItem[];
117 createResponse?: AuthConfigCreateResponse;
118 + onCreate?: (params: AuthConfigCreateParams) => void;
119 };
120
121 /**
@@ -611,13 +613,15 @@ export const TestLayer = (input?: TestLiveInput) =>
613 }
614 return Effect.succeed(found);
615 },
614 - createAuthConfig: () =>
615 - Effect.succeed(
616 + createAuthConfig: (params: AuthConfigCreateParams) => {
617 + authConfigsData.onCreate?.(params);
618 + return Effect.succeed(
619 authConfigsData.createResponse ?? {
620 auth_config: { id: 'ac_test', auth_scheme: 'OAUTH2', is_composio_managed: true },
621 toolkit: { slug: 'test' },
622 }
620 - ),
623 + );
624 + },
625 deleteAuthConfig: (nanoid: string) => {
626 const found = authConfigsData.items.find(item => item.id === nanoid);
627 if (!found) {
ts/packages/cli/test/src/commands/auth-configs/auth-configs.create.cmd.test.ts
+57
@@ -1,4 +1,5 @@
1 import { describe, expect, layer } from '@effect/vitest';
2 +import type { AuthConfigCreateParams } from '@composio/client/resources/auth-configs';
3 import { ConfigProvider, Effect } from 'effect';
4 import { extendConfigProvider } from 'src/services/config';
5 import { cli, TestLive, MockConsole } from 'test/__utils__';
@@ -181,4 +182,60 @@ describe('CLI: composio dev auth-configs create', () => {
182 );
183 }
184 );
185 +
186 + let capturedCreateAuthConfig: AuthConfigCreateParams | undefined;
187 +
188 + layer(
189 + TestLive({
190 + baseConfigProvider: testConfigProvider,
191 + ...dangerousDevConfig,
192 + authConfigsData: {
193 + createResponse: {
194 + auth_config: { id: 'ac_oauth', auth_scheme: 'OAUTH2', is_composio_managed: false },
195 + toolkit: { slug: 'shopify' },
196 + },
197 + onCreate: params => {
198 + capturedCreateAuthConfig = params;
199 + },
200 + },
201 + })
202 + )(
203 + '[Given] custom OAuth credentials and scopes [Then] nests them under auth_config.credentials',
204 + it => {
205 + it.scoped('sends custom OAuth settings inside credentials', () =>
206 + Effect.gen(function* () {
207 + capturedCreateAuthConfig = undefined;
208 +
209 + yield* cli([
210 + 'dev',
211 + 'auth-configs',
212 + 'create',
213 + '--toolkit',
214 + 'shopify',
215 + '--auth-scheme',
216 + 'OAUTH2',
217 + '--custom-credentials',
218 + '{"client_id":"my_client_id","client_secret":"my_client_secret"}',
219 + '--scopes',
220 + 'read_products, write_products',
221 + '--dangerously-allow',
222 + ]);
223 +
224 + expect(capturedCreateAuthConfig).toStrictEqual({
225 + toolkit: { slug: 'shopify' },
226 + auth_config: {
227 + type: 'use_custom_auth',
228 + authScheme: 'OAUTH2',
229 + name: undefined,
230 + credentials: {
231 + client_id: 'my_client_id',
232 + client_secret: 'my_client_secret',
233 + scopes: ['read_products', 'write_products'],
234 + },
235 + },
236 + });
237 + })
238 + );
239 + }
240 + );
241 });