Skip to content

Commit 4b4e71c

Browse files
committed
fix(webhooks): restore auth-first ordering and add credential resolution warning
- Revert parallel auth+preprocessing to sequential auth→preprocessing to prevent rate-limit exhaustion via unauthenticated requests - Add warning log when credential account resolution fails in background job
1 parent 7c80b26 commit 4b4e71c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

apps/sim/app/api/webhooks/trigger/[path]/route.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,13 @@ export async function POST(
7979
return reachabilityResponse
8080
}
8181

82-
// Parallelize auth verification with preprocessing — they are independent
83-
const [authError, preprocessResult] = await Promise.all([
84-
verifyProviderAuth(foundWebhook, foundWorkflow, request, rawBody, requestId),
85-
checkWebhookPreprocessing(foundWorkflow, foundWebhook, requestId),
86-
])
87-
82+
const authError = await verifyProviderAuth(
83+
foundWebhook,
84+
foundWorkflow,
85+
request,
86+
rawBody,
87+
requestId
88+
)
8889
if (authError) {
8990
if (webhooksForPath.length > 1) {
9091
logger.warn(`[${requestId}] Auth failed for webhook ${foundWebhook.id}, continuing to next`)
@@ -93,6 +94,7 @@ export async function POST(
9394
return authError
9495
}
9596

97+
const preprocessResult = await checkWebhookPreprocessing(foundWorkflow, foundWebhook, requestId)
9698
if (preprocessResult.error) {
9799
if (webhooksForPath.length > 1) {
98100
logger.warn(

apps/sim/background/webhook-execution.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,11 @@ async function executeWebhookJobInternal(
211211
: Promise.resolve(payload.credentialAccountUserId),
212212
])
213213
const credentialAccountUserId = resolvedCredentialUserId
214+
if (payload.credentialId && !credentialAccountUserId) {
215+
logger.warn(
216+
`[${requestId}] Failed to resolve credential account for credential ${payload.credentialId}`
217+
)
218+
}
214219

215220
if (!workflowData) {
216221
throw new Error(

0 commit comments

Comments
 (0)