ComposioHQ/composio · error · ValidationError

Invalid parameters passed to set webhook subscription

Error message

Invalid parameters passed to set webhook subscription

What it means

ValidationError('Invalid parameters passed to set webhook subscription') is thrown by Triggers.setWebhookSubscription when params fail SetWebhookSubscriptionParamsSchema.safeParse. The parsed webhookUrl is sent as webhook_url to the API, so this client-side guard ensures the URL (and any other params) are valid before the call. ZodError is attached as cause.

Source

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

  /**
   * Create or update the project webhook subscription used for webhook delivery.
   *
   * If a subscription already exists, the first subscription is updated. Otherwise a new
   * subscription is created. By default this subscribes to V3 trigger message events.
   *
   * @example
   * ```ts
   * await composio.triggers.setWebhookSubscription({
   *   webhookUrl: `${APP_URL}/webhooks/composio`,
   * });
   * ```
   */
  async setWebhookSubscription(params: SetWebhookSubscriptionParams): Promise<WebhookSubscription> {
    const parsedParams = SetWebhookSubscriptionParamsSchema.safeParse(params);

    if (!parsedParams.success) {
      throw new ValidationError(`Invalid parameters passed to set webhook subscription`, {
        cause: parsedParams.error,
      });
    }

    const body = {
      webhook_url: parsedParams.data.webhookUrl,
      enabled_events: parsedParams.data.enabledEvents ?? [...DefaultWebhookSubscriptionEvents],
      version: parsedParams.data.version ?? WebhookVersions.V3,
    };

    const existing = await this.client.get<RawWebhookSubscriptionListResponse>(
      WEBHOOK_SUBSCRIPTIONS_PATH,
      { query: { limit: 1 } }
    );
    const subscriptionId = firstWebhookSubscriptionId(existing);

    const subscription = subscriptionId
      ? await this.client.patch<RawWebhookSubscription>(

View on GitHub (pinned to 64b1b85502)

Solutions

  1. Ensure webhookUrl is a fully qualified https URL string before calling
  2. Validate config-derived URLs at app startup (new URL(...) round-trip) and fail fast if missing
  3. Inspect error.cause ZodError issues for the precise constraint that failed

Example fix

// before
await triggers.setWebhookSubscription({ webhookUrl: process.env.WEBHOOK_URL });

// after
const webhookUrl = process.env.WEBHOOK_URL;
if (!webhookUrl) throw new Error('WEBHOOK_URL not set');
await triggers.setWebhookSubscription({ webhookUrl: new URL(webhookUrl).toString() });
Defensive patterns

Strategy: validation

Validate before calling

function isValidWebhookUrl(url: unknown): url is string {
  if (typeof url !== 'string' || !url.trim()) return false;
  try { return new URL(url).protocol === 'https:'; } catch { return false; }
}
if (!isValidWebhookUrl(params.webhookUrl)) throw new Error('webhookUrl must be a valid https URL');

Type guard

const isValidWebhookUrl = (url: unknown): url is string =>
  typeof url === 'string' && /^https:\/\/.+\..+/.test(url.trim());

Try / catch

try {
  await triggers.setWebhookSubscription(params);
} catch (e) {
  if (e instanceof ValidationError) console.error('webhookUrl invalid:', e.cause?.issues);
}

Prevention

When it happens

Trigger: Calling triggers.setWebhookSubscription({ webhookUrl }) with a missing, non-string, or malformed webhookUrl — e.g. not a valid URL, a relative path, or an env var that resolved to undefined.

Common situations: webhookUrl read from an unset env var; passing http:// where https is required; passing a relative path like '/webhook'; tunnel URLs (ngrok) configured only in some environments.

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/3d130950c46b9ca3. Report an issue: GitHub.