Skip to content

Commit aba787e

Browse files
committed
fix(ashby): throw on unknown triggerId, always include webhookType
1 parent 3025414 commit aba787e

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

apps/sim/lib/webhooks/provider-subscriptions.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2187,7 +2187,7 @@ export async function createAshbyWebhookSubscription(
21872187
throw new Error('Trigger ID is required to create Ashby webhook.')
21882188
}
21892189

2190-
const webhookTypeMap: Record<string, string | undefined> = {
2190+
const webhookTypeMap: Record<string, string> = {
21912191
ashby_application_submit: 'applicationSubmit',
21922192
ashby_candidate_stage_change: 'candidateStageChange',
21932193
ashby_candidate_hire: 'candidateHire',
@@ -2197,6 +2197,10 @@ export async function createAshbyWebhookSubscription(
21972197
}
21982198

21992199
const webhookType = webhookTypeMap[triggerId]
2200+
if (!webhookType) {
2201+
throw new Error(`Unknown Ashby triggerId: ${triggerId}. Add it to webhookTypeMap.`)
2202+
}
2203+
22002204
const notificationUrl = `${getBaseUrl()}/api/webhooks/trigger/${path}`
22012205
const authString = Buffer.from(`${apiKey}:`).toString('base64')
22022206

@@ -2208,10 +2212,7 @@ export async function createAshbyWebhookSubscription(
22082212

22092213
const requestBody: Record<string, unknown> = {
22102214
requestUrl: notificationUrl,
2211-
}
2212-
2213-
if (webhookType) {
2214-
requestBody.webhookType = webhookType
2215+
webhookType,
22152216
}
22162217

22172218
const ashbyResponse = await fetch('https://api.ashbyhq.com/webhook.create', {

0 commit comments

Comments
 (0)