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

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

Conversation

@ShashankFC

@ShashankFC ShashankFC commented Feb 4, 2026 •

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)*

EntelligenceAI PR Summary

Adds retry tracking and cleanup logic for failed SMS workflow reminders to prevent infinite retries.

  • Added retryCount INTEGER field with default value 0 to WorkflowReminder table and Prisma schema
  • Modified SMS scheduling logic to increment retry counter on failures (both in catch blocks and unsuccessful attempts)
  • Enhanced cleanup query to delete reminders that are either past-due OR have exceeded 1 retry attempt
  • Included retryCount in select queries and type definitions for proper tracking

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

@entelligence-ai-pr-reviews entelligence-ai-pr-reviews Bot 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.

Walkthrough

This PR implements a retry mechanism for failed SMS workflow reminders to prevent infinite retry attempts and ensure proper cleanup. A new retryCount field is added to the WorkflowReminder database table with a default value of 0. The SMS reminder scheduling logic now tracks retry attempts by incrementing this counter when scheduling fails. The cleanup query is enhanced to remove both past-due reminders and reminders that have exceeded 1 retry attempt, ensuring failed reminders don't accumulate in the system indefinitely.

Changes

File(s) Summary
packages/prisma/schema.prisma
packages/prisma/migrations/20240508134359_add_retry_count_to_workflow_reminder/migration.sql
Added retryCount field to WorkflowReminder model/table as a non-nullable INTEGER with default value of 0 to track retry attempts for workflow reminders.
packages/features/ee/workflows/api/scheduleSMSReminders.ts Implemented retry mechanism by including retryCount in select queries and type definitions, incrementing the counter on SMS scheduling failures, and updating deletion query to remove reminders with retry count exceeding 1 using an OR condition.

Sequence Diagram

This diagram shows the interactions between components:

sequenceDiagram
    participant Scheduler as Workflow Scheduler
    participant DB as Prisma Database
    participant SMS as SMS Service
    
    Note over Scheduler,DB: Cleanup Phase
    Scheduler->>DB: deleteMany(past SMS OR retryCount > 1)
    DB-->>Scheduler: Deleted reminders
    
    Note over Scheduler,DB: Scheduling Phase
    Scheduler->>DB: findMany(upcoming reminders + retryCount)
    DB-->>Scheduler: unscheduledReminders[]
    
    alt no reminders found
        Scheduler-->>Scheduler: Return ok: true
    else reminders exist
        loop for each reminder
            Scheduler->>SMS: Schedule SMS
            
            alt SMS scheduled successfully
                SMS-->>Scheduler: scheduledSMS with sid
                Scheduler->>DB: delete reminder
                DB-->>Scheduler: Deleted
            else SMS scheduling failed
                SMS-->>Scheduler: No sid returned
                Scheduler->>DB: update(retryCount + 1)
                DB-->>Scheduler: Updated reminder
            end
            
            Note over Scheduler,DB: Error Handling
            opt error occurs
                Scheduler->>DB: update(retryCount + 1)
                DB-->>Scheduler: Updated reminder
                Scheduler->>Scheduler: Log error
            end
        end
    end
Loading

🔗 Cross-Repository Impact Analysis

Enable automatic detection of breaking changes across your dependent repositories. → Set up now

Learn more about Cross-Repository Analysis

What It Does

  • Automatically identifies repositories that depend on this code
  • Analyzes potential breaking changes across your entire codebase
  • Provides risk assessment before merging to prevent cross-repo issues

How to Enable

  1. Visit Settings → Code Management
  2. Configure repository dependencies
  3. Future PRs will automatically include cross-repo impact analysis!

Benefits

  • 🛡️ Prevent breaking changes across repositories
  • 🔍 Catch integration issues before they reach production
  • 📊 Better visibility into your multi-repo architecture

▶️ ⚡ AI Code Reviews for VS Code, Cursor, Windsurf
Install the extension

Note for Windsurf Please change the default marketplace provider to the following in the windsurf settings:

Marketplace Extension Gallery Service URL: https://marketplace.visualstudio.com/_apis/public/gallery

Marketplace Gallery Item URL: https://marketplace.visualstudio.com/items

Entelligence.ai can learn from your feedback. Simply add 👍 / 👎 emojis to teach it your preferences. More shortcuts below

Emoji Descriptions:

  • ⚠️ Potential Issue - May require further investigation.
  • 🔒 Security Vulnerability - Fix to ensure system safety.
  • 💻 Code Improvement - Suggestions to enhance code quality.
  • 🔨 Refactor Suggestion - Recommendations for restructuring code.
  • ℹ️ Others - General comments and information.

Interact with the Bot:

  • Send a message or request using the format:
    @entelligenceai + *your message*
Example: @entelligenceai Can you suggest improvements for this code?
  • Help the Bot learn by providing feedback on its responses.
    @entelligenceai + *feedback*
Example: @entelligenceai Do not comment on `save_auth` function !

Also you can trigger various commands with the bot by doing
@entelligenceai command

The current supported commands are

  1. config - shows the current config
  2. retrigger_review - retriggers the review

More commands to be added soon.

Comment on lines +39 to +43
retryCount: {
gt: 1,
},
},
],

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Correctness: The retryCount: { gt: 1 } condition in the OR block lacks a method: WorkflowMethods.SMS filter. This will cause the deletion of all reminder types (e.g., Email) that have exceeded the retry limit, not just SMS reminders. Add method: WorkflowMethods.SMS to the second branch of the OR array.

🤖 AI Agent Prompt for Cursor/Windsurf

📋 Copy this prompt to your AI coding assistant (Cursor, Windsurf, etc.) to get help fixing this issue

File: packages/features/ee/workflows/api/scheduleSMSReminders.ts. In the deleteMany OR clause (around lines 39-43), the new retryCount>1 branch lacks a method filter and will delete non-SMS reminders. Add `method: WorkflowMethods.SMS` to that branch so deletion remains scoped to SMS reminders only.

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.

2 participants