Skip to content

SMS workflow reminder retry count tracking#9

Open
everettbu wants to merge 1 commit into
sms-retry-basefrom
sms-retry-enhanced
Open

SMS workflow reminder retry count tracking#9
everettbu wants to merge 1 commit into
sms-retry-basefrom
sms-retry-enhanced

Conversation

@everettbu

@everettbu everettbu commented Jul 28, 2025

Copy link
Copy Markdown

Test 9

Summary by CodeRabbit

  • New Features
    • Introduced retry tracking for SMS reminders, allowing the system to increment and monitor the number of scheduling attempts.
    • Reminders that have failed to schedule more than once are now automatically removed.
  • Bug Fixes
    • Improved handling of failed SMS scheduling attempts by incrementing retry counts and managing retries more robustly.

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

coderabbitai Bot commented Jul 28, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

A new retryCount field has been introduced to the WorkflowReminder model and database table. The logic for scheduling SMS reminders now tracks and increments retryCount on failures, and deletes reminders that have been retried more than once. The code now also explicitly queries and updates this field as part of the scheduling process.

Changes

Cohort / File(s) Change Summary
Workflow Reminder Scheduling Logic
packages/features/ee/workflows/api/scheduleSMSReminders.ts
Added logic to increment retryCount on scheduling failures, delete reminders with retryCount > 1, and include retryCount in queries.
Database Migration
packages/prisma/migrations/20240508134359_add_retry_count_to_workflow_reminder/migration.sql
Added new retryCount column (INTEGER, default 0, non-null) to WorkflowReminder table.
Prisma Schema Update
packages/prisma/schema.prisma
Added retryCount Int @default(0) field to WorkflowReminder model.

Sequence Diagram(s)

sequenceDiagram
    participant Scheduler as SMS Reminder Scheduler
    participant DB as Database

    loop For each unscheduled reminder
        Scheduler->>DB: Query reminder (includes retryCount)
        alt Reminder scheduled successfully
            Scheduler->>DB: Update reminder as scheduled
        else Scheduling fails
            Scheduler->>DB: Increment retryCount
            alt retryCount > 1
                Scheduler->>DB: Delete reminder
            end
        end
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

In burrows deep, where reminders dwell,
A counter rises—retry, then quell.
If twice it stumbles, away it hops,
No more nudges, the cycle stops.
With every hop, the code grows neat—
SMS reminders, now complete!
🐇✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sms-retry-enhanced

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@everettbu

Copy link
Copy Markdown
Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Jul 28, 2025

Copy link
Copy Markdown
Contributor
✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@github-actions

Copy link
Copy Markdown
Contributor

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:

No release type found in pull request title "SMS workflow reminder retry count tracking". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 917c7b0 and 2dae0bf.

📒 Files selected for processing (3)
  • packages/features/ee/workflows/api/scheduleSMSReminders.ts (3 hunks)
  • packages/prisma/migrations/20240508134359_add_retry_count_to_workflow_reminder/migration.sql (1 hunks)
  • packages/prisma/schema.prisma (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
packages/features/ee/workflows/api/scheduleSMSReminders.ts (2)
packages/features/ee/workflows/lib/getWorkflowReminders.ts (2)
  • select (112-172)
  • PartialWorkflowReminder (35-40)
packages/prisma/index.ts (1)
  • prisma (39-39)
🔇 Additional comments (5)
packages/prisma/migrations/20240508134359_add_retry_count_to_workflow_reminder/migration.sql (1)

1-2: LGTM! Clean migration implementation.

The migration correctly adds the retryCount column as a non-nullable integer with a sensible default value of 0, ensuring existing records are properly handled.

packages/prisma/schema.prisma (1)

1000-1000: LGTM! Schema change is consistent with migration.

The retryCount field definition properly matches the database migration with appropriate type and default value.

packages/features/ee/workflows/api/scheduleSMSReminders.ts (3)

56-60: LGTM! Proper query extension for retryCount.

The select query correctly includes the retryCount field and the type annotation properly extends the existing type.


178-187: LGTM! Proper retry count increment on scheduling failure.

The logic correctly increments the retry count when SMS scheduling fails, maintaining proper failure tracking.


190-197: LGTM! Proper retry count increment on exceptions.

The error handling correctly tracks retry attempts when exceptions occur, ensuring consistent failure tracking across different error scenarios.

Comment on lines +31 to +43
OR: [
{
method: WorkflowMethods.SMS,
scheduledDate: {
lte: dayjs().toISOString(),
},
},
{
retryCount: {
gt: 1,
},
},
],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Critical logic error in deletion criteria.

The current OR condition will delete ANY workflow reminder (EMAIL, WHATSAPP, etc.) with retryCount > 1, not just SMS reminders. This could break other workflow types.

The logic should ensure both conditions apply only to SMS reminders:

  await prisma.workflowReminder.deleteMany({
    where: {
-      OR: [
-        {
-          method: WorkflowMethods.SMS,
-          scheduledDate: {
-            lte: dayjs().toISOString(),
-          },
-        },
-        {
-          retryCount: {
-            gt: 1,
-          },
-        },
-      ],
+      method: WorkflowMethods.SMS,
+      OR: [
+        {
+          scheduledDate: {
+            lte: dayjs().toISOString(),
+          },
+        },
+        {
+          retryCount: {
+            gt: 1,
+          },
+        },
+      ],
    },
  });
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
OR: [
{
method: WorkflowMethods.SMS,
scheduledDate: {
lte: dayjs().toISOString(),
},
},
{
retryCount: {
gt: 1,
},
},
],
await prisma.workflowReminder.deleteMany({
where: {
method: WorkflowMethods.SMS,
OR: [
{
scheduledDate: {
lte: dayjs().toISOString(),
},
},
{
retryCount: {
gt: 1,
},
},
],
},
});
🤖 Prompt for AI Agents
In packages/features/ee/workflows/api/scheduleSMSReminders.ts between lines 31
and 43, the OR condition incorrectly deletes any workflow with retryCount > 1
regardless of method type. To fix this, combine the conditions so that both
retryCount > 1 and method being SMS are checked together, ensuring only SMS
reminders meeting these criteria are deleted. Replace the separate OR conditions
with a single condition that includes method: WorkflowMethods.SMS along with the
retryCount or scheduledDate checks.

@github-actions

Copy link
Copy Markdown
Contributor

This PR is being marked as stale due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants