SMS workflow reminder retry count tracking#3
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>
Codoki PR ReviewSummary: Scope retry deletion to SMS, prevent data loss Issues (Critical & High only)
Showing top 1 issues. Critical: 1, High: 0. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 2/5 — Not ready to merge (1 critical · status: Requires changes) Sequence DiagramsequenceDiagram
participant Cron
participant API
participant DB
participant Twilio
Cron->>API: POST /scheduleSMSReminders
API->>DB: deleteMany({ OR: [...] })
API->>DB: findMany({ method: SMS, scheduled: false, scheduledDate <= now+7d })
loop for each reminder
API->>Twilio: scheduleSMS(sendTo, message, scheduledDate,...)
alt scheduledSMS truthy
API->>DB: update({ scheduled: true, referenceId })
else schedule failed or throws
API->>DB: update({ retryCount: +1 })
end
end
API-->>Cron: 200 { message: "SMS scheduled" }
React with 👍 or 👎 if you found this review useful. |
| }, | ||
| }, | ||
| { | ||
| retryCount: { |
There was a problem hiding this comment.
🛑 Critical: This deleteMany condition deletes any WorkflowReminder with retryCount > 1 regardless of method or scheduled status, causing unintended data loss (e.g., email reminders with retryCount 2 will be removed). Scope the retry cleanup to SMS reminders that are still unscheduled. Optionally, also filter findMany to scheduledDate >= now to avoid attempting to schedule past-dated reminders.
| retryCount: { | |
| ```suggestion | |
| where: { | |
| OR: [ | |
| { | |
| method: WorkflowMethods.SMS, | |
| scheduledDate: { | |
| lte: dayjs().toISOString(), | |
| }, | |
| }, | |
| { | |
| AND: [ | |
| { method: WorkflowMethods.SMS }, | |
| { scheduled: false }, | |
| { retryCount: { gt: 1 } }, | |
| ], | |
| }, | |
| ], | |
| }, |
No description provided.