Amazon Ergo 1.0 · 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.795

Published comments (2)

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

Lock-skipped SMS reminders are counted as failures and deleted — Lock-based skips now increment `retryCount`, so the `retryCount > 1` `deleteMany` deletes reminders after two cron runs instead of leaving them queued for delivery after an admin lifts the SMS lock. Count only delivery failures from the catch path; `scheduleSMS` in twilioProvider.ts returns `undefined` without sending when locked.

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

Retry-count update in catch can abort remaining SMS reminders — If `prisma.workflowReminder.update` throws (for example, Prisma `P2025` after a concurrent delete), the exception escapes the catch and aborts the handler, skipping every remaining reminder. Wrap this bookkeeping update in its own try/catch or use a non-throwing update so one stale reminder cannot stop 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.