SMS workflow reminder retry count tracking - #4
ShashankFC wants to merge 1 commit into
Conversation
* 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>
There was a problem hiding this comment.
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.prismapackages/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
🔗 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
- Visit Settings → Code Management
- Configure repository dependencies
- 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
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
config- shows the current configretrigger_review- retriggers the review
More commands to be added soon.
| retryCount: { | ||
| gt: 1, | ||
| }, | ||
| }, | ||
| ], |
There was a problem hiding this comment.
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.
Test 9nn
Summary by CodeRabbit
New Features
Bug Fixes
✏️ 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.
retryCountINTEGER field with default value 0 toWorkflowRemindertable and Prisma schemaretryCountin select queries and type definitions for proper tracking