Claude Sonnet 5.5 · Balanced

sms-workflow-reminder-retry-count-tracking-cal-com

cal.com · TypeScript · S · 30–99 lines · 3 files

The normal review, with one generalist agent. Judge: Claude Haiku 5.5.

Gold bugs found
2 of 5
Comments published
3
Comments matching a bug
2
Comments not matching
1
Cost of this PR
$0.187

Published comments (3)

highbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:38-42

SMS cron deletes non-SMS reminders with retryCount > 1 — Because the `retryCount: { gt: 1 }` branch isn't limited to SMS, this cron can delete email or WhatsApp reminders, including already scheduled ones. Move `method: WorkflowMethods.SMS` outside the OR, or add it to the `retryCount` branch.

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:189-198

Unguarded retryCount update in catch block can abort the reminder loop — If `prisma.workflowReminder.update` throws in the catch block (row deleted concurrently, DB down), the exception escapes the loop, skips the remaining reminders and makes the cron return an error. Wrap the update in its own try/catch and log the failure.

mediumbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:175-188

`retryCount` is not incremented when `message` is empty or `sendTo` is missing — Reminders with an invalid or absent phone number are never counted as failed, so the cron reselects them on every run until `scheduledDate`, which is the retry loop this PR should remove. Add an else branch that increments `retryCount` when `message` or `sendTo` is missing.

Gold bugs found (2)

highThe deleteMany OR clause applies retryCount > 1 without the SMS method filter, so the SMS cron deletes any workflow reminder (email, WhatsApp) with retryCount above 1.
mediumThe retry-count update inside the catch block is not guarded, so if it throws (for example the reminder was deleted concurrently) the error escapes the loop and the cron run fails, skipping the remaining reminders.

Gold bugs missed (3)

mediumretryCount is set to reminder.retryCount + 1 from a value read at the start of the run instead of an atomic increment, so overlapping runs can lose increments.
criticalClaims transient errors increment retryCount, so two runs during an outage delete the whole pending SMS reminder queue.
highSMS-sending locks are counted as failed scheduling attempts: scheduleSMS returns undefined for locked users/teams, retryCount is incremented, and after two cron runs the retryCount > 1 cleanup deletes future reminders even if sending is later unlocked.