Comprehensive workflow reminder management for booking lifecycle events#5
Comprehensive workflow reminder management for booking lifecycle events#5ShashankFC wants to merge 1 commit intoworkflow-queue-basefrom
Conversation
…re still sent (#7232) * small UI fix * fix cancelling scheduled emails * improve comments * delete reminders for rescheduled bookings * add migration file * cancel rescheduled bookings immediately * remove immediate delete for request reschedule --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com>
|
Hey there and thank you for opening this pull request! 👋🏼 We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted. Details: |
|
Claude finished @ShashankFC's task in 2m 59s —— View job Code Review CompleteTodo List
OverviewThis PR implements comprehensive workflow reminder management for booking lifecycle events (cancel/reschedule). The changes introduce a new Issues Found1. Critical: PR Title Doesn't Follow Conventional CommitsThe PR title "Comprehensive workflow reminder management for booking lifecycle events" needs a conventional commit prefix. Based on the changes, this should be: The bot comment flagged this - please update the PR title to include a valid prefix (fix, feat, refactor, etc.). 2. Bug: Missing null check in scheduleEmailReminders.ts (packages/features/ee/workflows/api/scheduleEmailReminders.ts:44-77)The new code cancels reminders marked as for (const reminder of remindersToCancel) {
await client.request({
url: "/v3/user/scheduled_sends",
method: "POST",
body: {
batch_id: reminder.referenceId, // ⚠️ Could be null
status: "cancel",
},
});Impact: Will throw an error if Fix: Add a null check similar to the pattern in for (const reminder of remindersToCancel) {
if (reminder.referenceId) {
await client.request({
url: "/v3/user/scheduled_sends",
method: "POST",
body: {
batch_id: reminder.referenceId,
status: "cancel",
},
});
}
// ... rest of the code
}3. Design Issue: Inconsistent deletion behavior between EMAIL and SMS (packages/features/ee/workflows/lib/reminders/)For EMAIL reminders, the code uses a soft-delete approach (marking as // emailReminderManager.ts:225-232
await prisma.workflowReminder.update({
where: { id: reminderId },
data: { cancelled: true },
});For SMS reminders, the code uses immediate hard-delete: // smsReminderManager.ts:181-185
await prisma.workflowReminder.delete({
where: { id: reminderId },
});Problem: This inconsistency means:
Recommendation: Consider making the behavior consistent. Either:
4. Migration Issue: Missing default value (packages/prisma/migrations/20230217230604_add_cancelled_to_workflow_reminder/migration.sql)The migration adds a nullable ALTER TABLE "WorkflowReminder" ADD COLUMN "cancelled" BOOLEAN;While nullable columns are fine, it would be clearer to set existing rows to ALTER TABLE "WorkflowReminder" ADD COLUMN "cancelled" BOOLEAN DEFAULT false;This makes the intent clearer: existing reminders are not cancelled. 5. Code Quality: Incorrect type annotation (packages/features/ee/workflows/api/scheduleEmailReminders.ts:54)const workflowRemindersToDelete: Prisma.Prisma__WorkflowReminderClient<WorkflowReminder, never>[] = [];This type is incorrect. const workflowRemindersToDelete: Promise<WorkflowReminder>[] = [];6. Potential Race Condition: CRON timing vs immediate operations (packages/features/ee/workflows/api/scheduleEmailReminders.ts)The CRON job cancels reminders scheduled "within the next hour": scheduledDate: {
lte: dayjs().add(1, "hour").toISOString(),
}However, when
Recommendation: Ensure the CRON job filters out already-processed reminders or handles errors gracefully. 7. Code Smell: Removed unused imports but changed signature (packages/features/bookings/lib/handleCancelBooking.ts:485-492)The refactor removed the Before: All deletes were in a single Consider if this could cause issues where a booking is deleted but reminders aren't, or vice versa. 8. Missing Error Handling: Silent failures (multiple files)Several places call delete functions without handling failures: // handleCancelBooking.ts:485-492
updatedBookings.forEach((booking) => {
booking.workflowReminders.forEach((reminder) => {
if (reminder.method === WorkflowMethods.EMAIL) {
deleteScheduledEmailReminder(reminder.id, reminder.referenceId); // No await, no error handling
} else if (reminder.method === WorkflowMethods.SMS) {
deleteScheduledSMSReminder(reminder.id, reminder.referenceId); // No await, no error handling
}
});
});These functions are async but aren't being awaited, and errors are only logged internally. This means:
Recommendation: Either await these calls properly or document that failures are acceptable. 9. Inconsistent Parameter Naming:
|
|
This PR is being marked as stale due to inactivity. |
Test 6nn---nReplicated from ai-code-review-evaluation/cal.com-greptile#6