{"record":{"id":"c91ff48ff3f58a85","repo":"ComposioHQ/composio","slug":"failed-to-parse-create-connected-account-link-opti","errorCode":null,"errorMessage":"Failed to parse create connected account link options","messagePattern":"Failed to parse create connected account link options","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/ConnectedAccounts.ts","lineNumber":382,"sourceCode":"   * const connectionRequest = await composio.connectedAccounts.link('user_123', 'auth_config_123', {\n   *   callbackUrl: 'https://your-app.com/callback'\n   * });\n   * const redirectUrl = connectionRequest.redirectUrl;\n   * console.log(`Visit: ${redirectUrl} to authenticate your account`);\n   *\n   * // Wait for the connection to be established\n   * const connectedAccount = await composio.connectedAccounts.waitForConnection(connectionRequest.id);\n   * ```\n   */\n  async link(\n    userId: string,\n    authConfigId: string,\n    options?: CreateConnectedAccountLinkOptions,\n    requestOptions?: ComposioRequestOptions\n  ): Promise<ConnectionRequest> {\n    const parsedLinkOptions = CreateConnectedAccountLinkOptionsSchema.safeParse(options || {});\n    if (!parsedLinkOptions.success) {\n      throw new ValidationError('Failed to parse create connected account link options', {\n        cause: parsedLinkOptions.error,\n      });\n    }\n\n    const opts = parsedLinkOptions.data;\n\n    // Mirror initiate(): guard against silently creating extra connections on\n    // the same auth config unless the caller explicitly opts in. The preflight\n    // list call honors the caller's signal too — the whole composite is\n    // cancellable as a single unit.\n    const existing = await this.list(\n      {\n        userIds: [userId],\n        authConfigIds: [authConfigId],\n        statuses: [ConnectedAccountStatuses.ACTIVE],\n      },\n      requestOptions\n    );","sourceCodeStart":364,"sourceCodeEnd":400,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/ConnectedAccounts.ts#L364-L400","documentation":"ValidationError thrown when the options object passed to ConnectedAccounts.link fails Zod validation against CreateConnectedAccountLinkOptionsSchema. The cause contains the Zod issues showing exactly which field (e.g. redirectUrl, allowMultiple) is invalid.","triggerScenarios":"Calling composio.connectedAccounts.link(authConfigId, options) with an options object containing invalid or wrongly-typed fields, e.g. a non-string redirectUrl or unknown enum value.","commonSituations":"Passing a misnamed field (redirectURL vs redirectUrl), wrong casing, or data from untyped API JSON directly into link().","solutions":["Inspect error.cause.issues for the failing field path","Match field names/types to CreateConnectedAccountLinkOptions (camelCase: redirectUrl, allowMultiple, …)","Run options through the schema (CreateConnectedAccountLinkOptionsSchema.parse) before calling link to get clearer errors"],"exampleFix":"// before\nawait c.connectedAccounts.link('github', { redirectURL: 'https://x' });\n// after\nawait c.connectedAccounts.link('github', { redirectUrl: 'https://x' });","handlingStrategy":"validation","validationCode":"const parsed = CreateConnectedAccountLinkOptionsSchema.safeParse(options);\nif (!parsed.success) console.error(parsed.error.issues);","typeGuard":"const isValidationError = (e: unknown): boolean => e instanceof ValidationError;","tryCatchPattern":"try { await ca.link(id, options); } catch (e) { if (e instanceof ValidationError) { /* read e.cause.issues */ } }","preventionTips":["Type options as CreateConnectedAccountLinkOptions","Pre-validate with the exported Zod schema"],"tags":["validation","zod","connected-accounts","typescript"],"backgroundTag":"schema-validation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}