Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 22, 22:00 UTC
Fix: Relax connected account types parsing (#1733)
Musthaq Ahamad committed
Jul 3, 2025 at 12:29 UTC
b1c35900a1d7533efd0f436508aac1898e3d6a6c
3 files changed
+23
-13
ts/packages/core/src/models/AuthScheme.ts
+3
-1
@@ -86,7 +86,9 @@ export class AuthScheme {
86
* @param params The API key parameters
87
* @returns ConnectionData object
88
*/
89
- static APIKey(params: BaseConnectionFields & { api_key: string }): ConnectionData {
89
+ static APIKey(
90
+ params: BaseConnectionFields & { api_key?: string; generic_api_key?: string }
91
+ ): ConnectionData {
92
return {
93
authScheme: AuthSchemeTypes.API_KEY,
94
val: {
ts/packages/core/src/models/ConnectedAccounts.ts
+14
-11
@@ -182,16 +182,18 @@ export class ConnectedAccounts {
182
);
183
}
184
185
- let state: ConnectionData | undefined = undefined;
186
- if (options?.config) {
187
- const connectionDataParsed = ConnectionDataSchema.safeParse(options.config);
188
- if (!connectionDataParsed.success) {
189
- throw new ValidationError('Failed to parse connection data', {
190
- cause: connectionDataParsed.error,
191
- });
192
- }
193
- state = connectionDataParsed.data;
194
- }
185
+ const state: ConnectionData | undefined = options?.config ?? undefined;
186
+ // @TODO: Commenting this out. This is a temporary fix to allow api_key to be optional, in future ideally we should fix this from API side
187
+
188
+ // if (options?.config) {
189
+ // const connectionDataParsed = ConnectionDataSchema.safeParse(options.config);
190
+ // if (!connectionDataParsed.success) {
191
+ // throw new ValidationError('Failed to parse connection data', {
192
+ // cause: connectionDataParsed.error,
193
+ // });
194
+ // }
195
+ // state = connectionDataParsed.data;
196
+ // }
197
198
const response = await this.client.connectedAccounts.create({
199
auth_config: {
@@ -202,7 +204,8 @@ export class ConnectedAccounts {
204
user_id: userId,
205
state,
206
},
205
- });
207
+ // @TODO: This is a temporary fix to allow api_key to be optional, in future ideally we should fix this from API side
208
+ } as ConnectedAccountCreateParamsRaw);
209
210
const redirectUrl =
211
typeof response.connectionData?.val?.redirectUrl === 'string'
ts/packages/core/src/types/connectedAccountAuthStates.types.ts
+6
-1
@@ -61,6 +61,10 @@ const BaseSchemeRaw = z
61
server_location: z.string().optional(),
62
// base_url only
63
base_url: z.string().optional(),
64
+ // for api key
65
+ api_key: z.string().optional(),
66
+ // for generic api key
67
+ generic_api_key: z.string().optional(),
68
})
69
.catchall(z.unknown());
70
@@ -235,7 +239,8 @@ const BasicConnectionDataSchema = BasicInitiatingSchema;
239
// API_KEY
240
const ApiKeyInitiatingSchema = BaseSchemeRaw.extend({
241
status: z.literal(ConnectionStatuses.ACTIVE),
238
- api_key: z.string(),
242
+ api_key: z.string().optional(),
243
+ generic_api_key: z.string().optional(),
244
}).catchall(z.unknown());
245
const ApiKeyConnectionDataSchema = ApiKeyInitiatingSchema;
246