-
Notifications
You must be signed in to change notification settings - Fork 0
SMS workflow reminder retry count tracking #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: sms-retry-base
Are you sure you want to change the base?
Conversation
* add retry count to workflow reminder * add logic to for retry count --------- Co-authored-by: CarinaWolli <[email protected]> Co-authored-by: Udit Takkar <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
Greptile OverviewConfidence Score: 1/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant Cron as Cron Job
participant API as scheduleSMSReminders
participant DB as Database
participant Twilio as Twilio API
Cron->>API: POST /scheduleSMSReminders
Note over API,DB: Cleanup Phase
API->>DB: deleteMany (scheduledDate <= now OR retryCount > 1)
Note right of DB: BUG: Deletes ALL reminders<br/>with retryCount > 1<br/>(not just SMS!)
Note over API,DB: Fetch Phase
API->>DB: findMany (SMS, unscheduled, scheduledDate <= 7 days)
DB-->>API: reminders with retryCount
loop For each reminder
Note over API: Build message & variables
API->>Twilio: scheduleSMS(phone, message, date)
alt Twilio Success
Twilio-->>API: response with SID
API->>DB: update(scheduled=true, referenceId=sid)
else Twilio Returns null/falsy
Note right of API: No error thrown
API->>DB: update(retryCount = retryCount + 1)
end
alt Exception Thrown
Note right of API: catch block
API->>DB: update(retryCount = retryCount + 1)
end
end
API-->>Cron: 200 OK
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3 files reviewed, 2 comments
| { | ||
| retryCount: { | ||
| gt: 1, | ||
| }, | ||
| }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
logic: deletion logic will remove ALL workflow reminders across different methods
the OR condition deletes reminders where retryCount > 1 WITHOUT checking method: WorkflowMethods.SMS, affecting EMAIL and WHATSAPP reminders too
| { | |
| retryCount: { | |
| gt: 1, | |
| }, | |
| }, | |
| { | |
| method: WorkflowMethods.SMS, | |
| retryCount: { | |
| gt: 1, | |
| }, | |
| }, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/features/ee/workflows/api/scheduleSMSReminders.ts
Line: 38:42
Comment:
**logic:** deletion logic will remove ALL workflow reminders across different methods
the OR condition deletes reminders where `retryCount > 1` WITHOUT checking `method: WorkflowMethods.SMS`, affecting EMAIL and WHATSAPP reminders too
```suggestion
{
method: WorkflowMethods.SMS,
retryCount: {
gt: 1,
},
},
```
How can I resolve this? If you propose a fix, please make it concise.| retryCount: { | ||
| gt: 1, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
style: hardcoded threshold of 1 retry - no constant or config
the gt: 1 means reminders are deleted after 2 failures, but there's no named constant or explanation for why this specific value
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/features/ee/workflows/api/scheduleSMSReminders.ts
Line: 39:40
Comment:
**style:** hardcoded threshold of 1 retry - no constant or config
the `gt: 1` means reminders are deleted after 2 failures, but there's no named constant or explanation for why this specific value
How can I resolve this? If you propose a fix, please make it concise.
Test 9
Replicated from ai-code-review-evaluation/cal.com-greptile#9