Skip to content

Conversation

@hbjORbj
Copy link
Contributor

@hbjORbj hbjORbj commented Nov 21, 2025

What does this PR do?

  • Removes the circular dep between packages/features/ee/workflows/lib/reminders/reminderScheduler.ts and packages/features/ee/billing/credit-service.ts
  • I created WorkflowReminderRepository for prisma queries and made cancelScheduledMessagesAndScheduleEmails accept pre-computed userIdsWithNoCredits parameter

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A - internal refactoring only
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Covered by existing tests

…ervice

- Created WorkflowReminderRepository to handle workflow reminder queries
- Refactored cancelScheduledMessagesAndScheduleEmails to accept userIdsWithoutCredits parameter
- Moved credit-checking logic from workflows to CreditService
- Changed dynamic import to static import in CreditService
- Updated tests to pass userIdsWithoutCredits parameter
- Removed unused imports (prisma, WorkflowMethods)

This creates a one-way dependency (billing -> workflows) and follows the repository pattern by removing direct Prisma usage from reminderScheduler.

Co-Authored-By: [email protected] <[email protected]>
@devin-ai-integration
Copy link
Contributor

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR that start with 'DevinAI' or '@devin'.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

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

2 issues found across 4 files

Prompt for AI agents (all 2 issues)

Understand the root cause of the following 2 issues and fix them.


<file name="packages/features/ee/billing/credit-service.ts">

<violation number="1" location="packages/features/ee/billing/credit-service.ts:608">
Team-level credit exhaustion no longer cancels SMS reminders because the membership lookup passes the teamId to a userId-based query and the returned rows lack userId entirely, so the list of out-of-credit members is always empty.</violation>

<violation number="2" location="packages/features/ee/billing/credit-service.ts:634">
Rule violated: **Avoid Logging Sensitive Information**

Do not log the full `result` object because `LowCreditBalanceResult` holds user and admin names/emails; log only non-PII identifiers instead.</violation>
</file>

Reply to cubic to teach it or ask questions. Re-run a review with @cubic-dev-ai review this PR

- Use MembershipRepository.listAcceptedTeamMemberIds instead of findAllAcceptedPublishedTeamMemberships
- Re-add prisma import to reminderScheduler.ts for UserRepository
- Update WorkflowReminderRepository to use WorkflowActions enum instead of string

Co-Authored-By: [email protected] <[email protected]>
@vercel
Copy link

vercel bot commented Nov 21, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Nov 22, 2025 3:38am
cal-eu Ignored Ignored Nov 22, 2025 3:38am

@github-actions
Copy link
Contributor

E2E results are ready!

@hbjORbj hbjORbj merged commit 8b65261 into main Nov 24, 2025
60 of 62 checks passed
@hbjORbj hbjORbj deleted the devin/fix-circular-dependency-1763729923 branch November 24, 2025 08:00
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.

4 participants