feat(tools): add batch email sending utility#334
Conversation
|
Warning Review limit reached
More reviews will be available in 35 minutes and 35 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more credits in the billing tab to continue. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughA new Node.js script ( ChangesStudent Onboarding Email Sender
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 6
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@tools/db-queries/emails.txt`:
- Line 1: The file tools/db-queries/emails.txt contains a real personal email
address (senkuishigami@gmail.com) on line 1, which is PII and violates the
placeholder-only workflow. Replace this real email address with a non-routable
placeholder email address such as student1@example.com or similar format that
follows the project's data seeding conventions.
In `@tools/send-student-emails.js`:
- Line 53: The console.log statements logging the email variable on lines 53 and
60 expose full email addresses as PII in the console output. Modify both
console.log calls to mask or hash the local part of the email address before
logging instead of logging the full email directly. Extract the local part
before the @ symbol and replace it with asterisks or a hash, keeping the domain
portion intact for reference (e.g., "****`@example.com`" format).
- Around line 6-9: The Resend client is being initialized without validating
that an API key is available, which defers the failure to send-time and makes
troubleshooting harder. Add an explicit guard check before the Resend client
initialization that verifies at least one of the API key environment variables
(RESEND_API_KEY_2 or RESEND_API_KEY) is set. If neither is present, throw an
error or exit the process immediately with a clear error message indicating the
missing API key configuration, then only proceed to create the Resend instance
if the validation passes.
- Line 39: The file path in the path.join call on line 39 is looking for
emails.txt directly in the tools directory, but this PR has moved the emails.txt
file to the db-queries subdirectory. Update the path.join call to include the
db-queries directory in the path hierarchy so it correctly resolves to
tools/db-queries/emails.txt instead of tools/emails.txt, which will prevent the
ENOENT file not found error.
- Around line 46-47: The batchSize variable on line 46 lacks validation and
accepts negative values, which when passed to the slice method on line 47 causes
unintended behavior by slicing from the start to a negative index, potentially
sending almost all emails. Add validation after parsing the batchSize from
process.argv[2] to ensure it is a positive integer greater than 0, and either
throw an error with a clear message or use a default value if the validation
fails.
- Line 15: The fallback sender email in the from field is hardcoded to
onboarding@resend.dev, which doesn't match the established email contract used
elsewhere in the project's email service logic. Replace this fallback value with
the same fallback sender pattern that is already used by existing email service
logic in the project to ensure consistency and avoid unverified sender policy
failures.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 65453ee8-baf0-4b21-a3fe-cd0b14543590
📒 Files selected for processing (2)
tools/db-queries/emails.txttools/send-student-emails.js
Summary
Adds a utility script under
tools/for sending outreach emails in configurable batches using Resend.This script is intended for manual user acquisition campaigns, allowing maintainers to send a limited number of emails at a time (e.g. 100 emails per run) to avoid provider limits and gradually onboard new users.
Changes
tools/send-student-emails.jstools/emails.txtas the email source fileUsage
Populate
tools/emails.txt:Run the script:
Examples:
Example Workflow
tools/emails.txtNotes
tools/emails.txtcontains placeholder/example entries only.Testing
Tested locally:
Actual email delivery testing requires a valid Resend API key and sender configuration.
Summary by CodeRabbit