Skip to content

SMS workflow reminder retry count tracking#4

Open
ShashankFC wants to merge 1 commit into
sms-retry-basefrom
sms-retry-enhanced
Open

SMS workflow reminder retry count tracking#4
ShashankFC wants to merge 1 commit into
sms-retry-basefrom
sms-retry-enhanced

Conversation

@ShashankFC

Copy link
Copy Markdown

Test 9nn

Summary by CodeRabbit

  • New Features

    • Implemented automatic retry capability for SMS reminders to handle delivery failures.
  • Bug Fixes

    • Improved error handling for failed SMS reminder deliveries with enhanced tracking and retry mechanisms.

✏️ Tip: You can customize this high-level summary in your review settings.

nn---n*Replicated from [ai-code-review-evaluation/cal.com-coderabbit#9](https://github.com/ai-code-review-evaluation/cal.com-coderabbit/pull/9)*

* add retry count to workflow reminder

* add logic to for retry count

---------

Co-authored-by: CarinaWolli <wollencarina@gmail.com>
Co-authored-by: Udit Takkar <53316345+Udit-takkar@users.noreply.github.com>
@ShashankFC ShashankFC requested a review from Copilot January 30, 2026 10:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds retry tracking for SMS workflow reminders to handle delivery failures. The implementation adds a retryCount field to the WorkflowReminder model and includes logic to increment the count on failures and clean up reminders that have exceeded the retry threshold.

Changes:

  • Added retryCount field to the WorkflowReminder database model with a default value of 0
  • Updated cleanup logic to delete reminders that have exceeded 1 retry attempt
  • Implemented retry count incrementing for both SMS scheduling failures and catch-all error scenarios

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/prisma/schema.prisma Adds retryCount integer field to WorkflowReminder model
packages/prisma/migrations/20240508134359_add_retry_count_to_workflow_reminder/migration.sql Database migration to add the retryCount column
packages/features/ee/workflows/api/scheduleSMSReminders.ts Implements retry logic including cleanup conditions, field selection, and retry count updates on failures

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +31 to +43
OR: [
{
method: WorkflowMethods.SMS,
scheduledDate: {
lte: dayjs().toISOString(),
},
},
{
retryCount: {
gt: 1,
},
},
],

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cleanup condition deletes reminders with retryCount > 1, which means reminders are only deleted after 2 failed attempts. However, this condition is in an OR clause with the scheduled date check, meaning reminders could be deleted immediately if their scheduledDate has passed, regardless of retry count. The retry count condition should be combined with the method and scheduledDate checks using AND logic to ensure proper retry behavior before cleanup.

Suggested change
OR: [
{
method: WorkflowMethods.SMS,
scheduledDate: {
lte: dayjs().toISOString(),
},
},
{
retryCount: {
gt: 1,
},
},
],
method: WorkflowMethods.SMS,
scheduledDate: {
lte: dayjs().toISOString(),
},
retryCount: {
gt: 1,
},

Copilot uses AI. Check for mistakes.
Comment on lines +190 to +197
await prisma.workflowReminder.update({
where: {
id: reminder.id,
},
data: {
retryCount: reminder.retryCount + 1,
},
});

Copilot AI Jan 30, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The retry count increment logic is duplicated in both the else block (lines 179-186) and the catch block (lines 190-197). Consider extracting this into a helper function to reduce duplication and improve maintainability.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants