Claude Opus 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
- 3 of 5
- Comments published
- 4
- Comments matching a bug
- 3
- Comments not matching
- 1
- Cost of this PR
- $0.586
Published comments (4)
Locked SMS accounts count as retries, so their reminders get deleted — When `isLockedForSMSSending` makes `twilio.scheduleSMS` return undefined, this branch still increments `retryCount`, so the reminder is permanently deleted after two cron runs even if the account is later unlocked. Increment `retryCount` only for real delivery failures, not intentional locks.
Temporary SMS scheduling errors count toward reminder deletion — A `checkSMSRateLimit` rejection or brief Twilio/network outage still increments `retryCount`, so two such failures delete a valid reminder that would have succeeded later. Increment only for permanent failures, such as Twilio invalid-number error codes, and let temporary errors retry.
Unguarded retryCount update in catch block aborts remaining reminders on failure — If `prisma.workflowReminder.update` throws here (e.g., P2025 when the record was deleted concurrently), the handler rejects and every remaining reminder in this run is skipped. Wrap the update in its own try/catch, or use `updateMany`, which doesn't throw when no row matches.
Unindexed `retryCount` OR branch forces a full WorkflowReminder table scan — No index in `schema.prisma` covers `retryCount`, so every cron run scans the whole `WorkflowReminder` table. Add the `WorkflowMethods.SMS` `method` filter to this branch so the existing method/scheduled/scheduledDate index applies, or add an index on `retryCount`.