Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix(polling): address PR review feedback
- Add archivedAt filters to fetchActiveWebhooks query, matching
  findWebhookAndWorkflow in processor.ts to prevent polling archived
  webhooks/workflows
- Move provider validation after auth check to prevent provider
  enumeration by unauthenticated callers
- Fix inconsistent pollingIdempotency import path in outlook.ts to
  match other handlers

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
  • Loading branch information
waleedlatif1 and claude committed Apr 8, 2026
commit 4a1000c0d87ccd218f65342601b821d83fece2a3
8 changes: 4 additions & 4 deletions apps/sim/app/api/webhooks/poll/[provider]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ export async function GET(
const { provider } = await params
const requestId = generateShortId()

if (!VALID_POLLING_PROVIDERS.has(provider)) {
return NextResponse.json({ error: `Unknown polling provider: ${provider}` }, { status: 404 })
}

const LOCK_KEY = `${provider}-polling-lock`
let lockValue: string | undefined

try {
const authError = verifyCronAuth(request, `${provider} webhook polling`)
if (authError) return authError

if (!VALID_POLLING_PROVIDERS.has(provider)) {
return NextResponse.json({ error: `Unknown polling provider: ${provider}` }, { status: 404 })
}

lockValue = requestId
const locked = await acquireLock(LOCK_KEY, lockValue, LOCK_TTL_SECONDS)
if (!locked) {
Expand Down
2 changes: 1 addition & 1 deletion apps/sim/lib/webhooks/polling/outlook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { htmlToText } from 'html-to-text'
import { pollingIdempotency } from '@/lib/core/idempotency'
import { pollingIdempotency } from '@/lib/core/idempotency/service'
import type { PollingProviderHandler, PollWebhookContext } from '@/lib/webhooks/polling/types'
import {
markWebhookFailed,
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/lib/webhooks/polling/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ export async function fetchActiveWebhooks(
and(
eq(webhook.provider, provider),
eq(webhook.isActive, true),
isNull(webhook.archivedAt),
eq(workflow.isDeployed, true),
isNull(workflow.archivedAt),
or(
eq(webhook.deploymentVersionId, workflowDeploymentVersion.id),
and(isNull(workflowDeploymentVersion.id), isNull(webhook.deploymentVersionId))
Expand Down
Loading