GPT-6.1 Sol · Heavy

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

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

The generalist plus 9 specialist lens agents in parallel, then the same verify and dedup steps. 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.548

Published comments (3)

highbugpackages/features/ee/workflows/api/scheduleSMSReminders.ts:31-43

SMS cleanup deletes retry-exhausted reminders of other methods — Email or WhatsApp reminders with `retryCount > 1` can be deleted regardless of their scheduled date. Move `method: WorkflowMethods.SMS` outside `OR` so both deletion conditions apply only to SMS reminders.

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

Retry bookkeeping failures abort processing of subsequent SMS reminders — If Prisma remains unavailable after a processing failure, `prisma.workflowReminder.update` can throw from the per-reminder catch and prevent subsequent reminders from being processed. Add separate error handling around the retry update so bookkeeping failures cannot escape that catch.

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

Deleted reminders can make the SMS error handler throw — An overlapping scheduler invocation can delete an in-flight reminder, causing `prisma.workflowReminder.update` in the error handler to throw and interrupt remaining reminders. Use `prisma.workflowReminder.updateMany` with `reminder.id` so an already-deleted row does not cause another failure.

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.