DeepSeek V4 Pro · 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 Opus 5.5.

Gold bugs found
2 of 6
Comments published
2
Comments matching a bug
2
Comments not matching
0
Cost of this PR
$0.390

Published comments (2)

criticalbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:178-187

SMS-locked accounts increment retryCount and delete reminders after two runs — A locked account or team is a reversible state, not a send failure, so counting each run as a retry causes `deleteMany` to remove reminders after two cron passes. Signal the locked case distinctly from `scheduleSMS` and skip `retryCount` updates for it. **Also found in:** - `packages/features/ee/workflows/api/scheduleSMSReminders.ts:189-199`

highbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:190-197

Catch block's unhandled retry update can abort SMS batch — An unhandled `prisma.workflowReminder.update` failure here can abort the whole `for` loop and return 500, skipping all remaining reminders. Wrap this update in its own try/catch or log-and-continue so one missing record cannot crash the batch.

Gold bugs found (2)

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.
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.

Gold bugs missed (4)

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.
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.
criticalClaims transient errors increment retryCount, so two runs during an outage delete the whole pending SMS reminder queue.
mediumscheduleWhatsappReminders never increments retryCount on Twilio failure, so failing WhatsApp reminders are retried on every cron run and never reach the retryCount > 1 cleanup added for SMS.