ComposioHQ/composio · error · ValidationError

Invalid parameters passed to create trigger

Error message

Invalid parameters passed to create trigger

What it means

ValidationError('Invalid parameters passed to create trigger') is thrown by Triggers.create when body fails TriggerInstanceUpsertParamsSchema.safeParse(body ?? {}). It fires after the userId check; an omitted body is validated as {} and can still fail if the trigger requires configuration. The ZodError cause lists failing fields such as triggerConfig or connectedAccountId.

Source

Thrown at ts/packages/core/src/models/Triggers.ts:338

   * @param {string} userId - The user id of the trigger instance
   * @param {string} slug - The slug of the trigger instance
   * @param {TriggerInstanceUpsertParams} body - The parameters to create the trigger instance
   * @returns {Promise<TriggerInstanceUpsertResponse>} The created trigger instance
   */
  async create(
    userId: string,
    slug: string,
    body?: TriggerInstanceUpsertParams,
    requestOptions?: ComposioRequestOptions
  ): Promise<TriggerInstanceUpsertResponse> {
    if (!userId?.trim()) {
      throw new ValidationError(`A non-empty userId is required to create a trigger`);
    }

    const parsedBody = TriggerInstanceUpsertParamsSchema.safeParse(body ?? {});

    if (!parsedBody.success) {
      throw new ValidationError(`Invalid parameters passed to create trigger`, {
        cause: parsedBody.error,
      });
    }

    // Validate the trigger slug up-front so callers get a clear client-side
    // `ComposioTriggerTypeNotFoundError`. The Python SDK mirrors this behavior.
    try {
      await this.getType(slug, requestOptions);
    } catch (error) {
      // The trigger types endpoint returns 400 (not 404) for an unknown slug.
      if (error instanceof APIError && (error.status === 400 || error.status === 404)) {
        throw new ComposioTriggerTypeNotFoundError(`Trigger type ${slug} not found`, {
          cause: error,
          possibleFixes: [
            `Please check the trigger slug`,
            `Please check the provided version of toolkit has the trigger`,
            `Visit the toolkit page to see the available triggers`,
          ],

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Inspect error.cause ZodError issues to see which body fields failed
  2. Check the trigger type (triggers.getType(slug)) for the config it requires and supply those fields
  3. Use camelCase keys matching the SDK schema and pre-validate with the exported schema in tests

Example fix

// before
await triggers.create(userId, 'github_issue_opened');

// after
await triggers.create(userId, 'github_issue_opened', {
  triggerConfig: { repository: 'org/repo' },
});
Defensive patterns

Strategy: validation

Validate before calling

import { TriggerInstanceUpsertParamsSchema } from '@composio/core';
const ok = TriggerInstanceUpsertParamsSchema.safeParse(body ?? {});
if (!ok.success) {
  throw new Error(ok.error.issues.map(i => `${i.path}: ${i.message}`).join('; '));
}

Type guard

const hasTriggerConfig = (b: unknown): b is { triggerConfig: Record<string, unknown> } =>
  typeof (b as any)?.triggerConfig === 'object' && (b as any).triggerConfig !== null;

Try / catch

try {
  await triggers.create(userId, slug, body);
} catch (e) {
  if (e instanceof ValidationError && /create trigger/.test(e.message)) {
    console.error(e.cause?.issues);
  }
}

Prevention

When it happens

Trigger: Calling triggers.create(userId, slug, body) where body has wrong types (triggerConfig not an object), unknown keys, or omits required configuration — or calling with no body at all when the schema demands config.

Common situations: Forgetting the repo/project to watch in triggerConfig; using snake_case keys from API docs; nested config values with wrong types after an SDK schema update.

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/561c15a87ea43dab. Report an issue: GitHub.