ComposioHQ/composio · error · ValidationError

Failed to parse create connected account link options

Error message

Failed to parse create connected account link options

What it means

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.

Source

Thrown at ts/packages/core/src/models/ConnectedAccounts.ts:382

   * const connectionRequest = await composio.connectedAccounts.link('user_123', 'auth_config_123', {
   *   callbackUrl: 'https://your-app.com/callback'
   * });
   * const redirectUrl = connectionRequest.redirectUrl;
   * console.log(`Visit: ${redirectUrl} to authenticate your account`);
   *
   * // Wait for the connection to be established
   * const connectedAccount = await composio.connectedAccounts.waitForConnection(connectionRequest.id);
   * ```
   */
  async link(
    userId: string,
    authConfigId: string,
    options?: CreateConnectedAccountLinkOptions,
    requestOptions?: ComposioRequestOptions
  ): Promise<ConnectionRequest> {
    const parsedLinkOptions = CreateConnectedAccountLinkOptionsSchema.safeParse(options || {});
    if (!parsedLinkOptions.success) {
      throw new ValidationError('Failed to parse create connected account link options', {
        cause: parsedLinkOptions.error,
      });
    }

    const opts = parsedLinkOptions.data;

    // Mirror initiate(): guard against silently creating extra connections on
    // the same auth config unless the caller explicitly opts in. The preflight
    // list call honors the caller's signal too — the whole composite is
    // cancellable as a single unit.
    const existing = await this.list(
      {
        userIds: [userId],
        authConfigIds: [authConfigId],
        statuses: [ConnectedAccountStatuses.ACTIVE],
      },
      requestOptions
    );

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Inspect error.cause.issues for the failing field path
  2. Match field names/types to CreateConnectedAccountLinkOptions (camelCase: redirectUrl, allowMultiple, …)
  3. Run options through the schema (CreateConnectedAccountLinkOptionsSchema.parse) before calling link to get clearer errors

Example fix

// before
await c.connectedAccounts.link('github', { redirectURL: 'https://x' });
// after
await c.connectedAccounts.link('github', { redirectUrl: 'https://x' });
Defensive patterns

Strategy: validation

Validate before calling

const parsed = CreateConnectedAccountLinkOptionsSchema.safeParse(options);
if (!parsed.success) console.error(parsed.error.issues);

Type guard

const isValidationError = (e: unknown): boolean => e instanceof ValidationError;

Try / catch

try { await ca.link(id, options); } catch (e) { if (e instanceof ValidationError) { /* read e.cause.issues */ } }

Prevention

When it happens

Trigger: 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.

Common situations: Passing a misnamed field (redirectURL vs redirectUrl), wrong casing, or data from untyped API JSON directly into link().

Understand the failure class

Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.

Related errors


AI-assisted analysis of ComposioHQ/composio@64b1b85502 (2026-08-28). Data as JSON: /api/errors/c91ff48ff3f58a85. Report an issue: GitHub.