Skip to content

Commit ee3290a

Browse files
committed
fix(webhooks): replace error as Error casts with toError() across providers
Replace all (error as Error) casts with toError() from @sim/utils/errors in airtable and hubspot providers, per global standard in CLAUDE.md. Adds toError import to airtable.ts.
1 parent b5aed85 commit ee3290a

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

apps/sim/lib/webhooks/providers/airtable.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { db } from '@sim/db'
33
import { account, webhook } from '@sim/db/schema'
44
import { createLogger } from '@sim/logger'
55
import { safeCompare } from '@sim/security/compare'
6+
import { toError } from '@sim/utils/errors'
67
import { eq } from 'drizzle-orm'
78
import { NextResponse } from 'next/server'
89
import { validateAirtableId } from '@/lib/core/security/input-validation'
@@ -404,7 +405,7 @@ async function fetchAndProcessAirtablePayloads(
404405
{
405406
webhookId: webhookData.id,
406407
workflowId: workflowData.id,
407-
error: (error as Error).message,
408+
error: toError(error).message,
408409
}
409410
)
410411
}
@@ -449,7 +450,7 @@ export const airtableHandler: WebhookProviderHandler = {
449450
}
450451
} catch (error) {
451452
logger.error(`[${requestId}] Error verifying Airtable MAC signature`, {
452-
error: (error as Error).message,
453+
error: toError(error).message,
453454
})
454455
return new NextResponse('Unauthorized - Signature verification error', { status: 401 })
455456
}
@@ -580,7 +581,7 @@ export const airtableHandler: WebhookProviderHandler = {
580581
},
581582
}
582583
} catch (error: unknown) {
583-
const err = error as Error
584+
const err = toError(error)
584585
logger.error(
585586
`[${requestId}] Exception during Airtable webhook creation for webhook ${webhookRecord.id}.`,
586587
{
@@ -702,7 +703,7 @@ export const airtableHandler: WebhookProviderHandler = {
702703
} catch (e: unknown) {
703704
externalIdLookupFailed = true
704705
logger.warn(`[${requestId}] Error attempting to resolve Airtable externalId`, {
705-
error: (e as Error)?.message,
706+
error: toError(e).message,
706707
})
707708
}
708709
}
@@ -755,7 +756,7 @@ export const airtableHandler: WebhookProviderHandler = {
755756
})
756757
}
757758
} catch (error: unknown) {
758-
const err = error as Error
759+
const err = toError(error)
759760
logger.error(`[${requestId}] Error deleting Airtable webhook`, {
760761
webhookId: webhookRecord.id,
761762
error: err.message,

apps/sim/lib/webhooks/providers/hubspot.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import crypto from 'crypto'
22
import { createLogger } from '@sim/logger'
33
import { safeCompare } from '@sim/security/compare'
4+
import { toError } from '@sim/utils/errors'
45
import { NextResponse } from 'next/server'
56
import type {
67
AuthContext,
@@ -41,7 +42,7 @@ export const hubspotHandler: WebhookProviderHandler = {
4142
}
4243
} catch (error) {
4344
logger.error(`[${requestId}] Error verifying HubSpot signature`, {
44-
error: (error as Error).message,
45+
error: toError(error).message,
4546
})
4647
return new NextResponse('Unauthorized - Signature verification error', { status: 401 })
4748
}

0 commit comments

Comments
 (0)