{"record":{"id":"3d130950c46b9ca3","repo":"ComposioHQ/composio","slug":"invalid-parameters-passed-to-set-webhook-subscript","errorCode":null,"errorMessage":"Invalid parameters passed to set webhook subscription","messagePattern":"Invalid parameters passed to set webhook subscription","errorType":"validation","errorClass":"ValidationError","httpStatus":null,"severity":"error","filePath":"ts/packages/core/src/models/Triggers.ts","lineNumber":240,"sourceCode":"\n  /**\n   * Create or update the project webhook subscription used for webhook delivery.\n   *\n   * If a subscription already exists, the first subscription is updated. Otherwise a new\n   * subscription is created. By default this subscribes to V3 trigger message events.\n   *\n   * @example\n   * ```ts\n   * await composio.triggers.setWebhookSubscription({\n   *   webhookUrl: `${APP_URL}/webhooks/composio`,\n   * });\n   * ```\n   */\n  async setWebhookSubscription(params: SetWebhookSubscriptionParams): Promise<WebhookSubscription> {\n    const parsedParams = SetWebhookSubscriptionParamsSchema.safeParse(params);\n\n    if (!parsedParams.success) {\n      throw new ValidationError(`Invalid parameters passed to set webhook subscription`, {\n        cause: parsedParams.error,\n      });\n    }\n\n    const body = {\n      webhook_url: parsedParams.data.webhookUrl,\n      enabled_events: parsedParams.data.enabledEvents ?? [...DefaultWebhookSubscriptionEvents],\n      version: parsedParams.data.version ?? WebhookVersions.V3,\n    };\n\n    const existing = await this.client.get<RawWebhookSubscriptionListResponse>(\n      WEBHOOK_SUBSCRIPTIONS_PATH,\n      { query: { limit: 1 } }\n    );\n    const subscriptionId = firstWebhookSubscriptionId(existing);\n\n    const subscription = subscriptionId\n      ? await this.client.patch<RawWebhookSubscription>(","sourceCodeStart":222,"sourceCodeEnd":258,"githubUrl":"https://github.com/ComposioHQ/composio/blob/64b1b85502b1beeb2379e6c9e8bf1104504fa637/ts/packages/core/src/models/Triggers.ts#L222-L258","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Ensure webhookUrl is a fully qualified https URL string before calling","Validate config-derived URLs at app startup (new URL(...) round-trip) and fail fast if missing","Inspect error.cause ZodError issues for the precise constraint that failed"],"exampleFix":"// before\nawait triggers.setWebhookSubscription({ webhookUrl: process.env.WEBHOOK_URL });\n\n// after\nconst webhookUrl = process.env.WEBHOOK_URL;\nif (!webhookUrl) throw new Error('WEBHOOK_URL not set');\nawait triggers.setWebhookSubscription({ webhookUrl: new URL(webhookUrl).toString() });","handlingStrategy":"validation","validationCode":"function isValidWebhookUrl(url: unknown): url is string {\n  if (typeof url !== 'string' || !url.trim()) return false;\n  try { return new URL(url).protocol === 'https:'; } catch { return false; }\n}\nif (!isValidWebhookUrl(params.webhookUrl)) throw new Error('webhookUrl must be a valid https URL');","typeGuard":"const isValidWebhookUrl = (url: unknown): url is string =>\n  typeof url === 'string' && /^https:\\/\\/.+\\..+/.test(url.trim());","tryCatchPattern":"try {\n  await triggers.setWebhookSubscription(params);\n} catch (e) {\n  if (e instanceof ValidationError) console.error('webhookUrl invalid:', e.cause?.issues);\n}","preventionTips":["Validate webhook URLs from config/env at app startup","Use publicly reachable https URLs (tunnels for local dev)","Fail fast at boot on missing WEBHOOK_URL instead of at subscription time"],"tags":["composio","zod","validation","webhook","triggers","typescript"],"backgroundTag":"schema-validation-failed","analyzedSha":"64b1b85502b1beeb2379e6c9e8bf1104504fa637","analyzedAt":"2026-08-28T15:39:33.623Z","schemaVersion":2},"datasetVersion":"2026-08-28T16:17:29.566Z"}