-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Upgrade Resend #3170
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
Upgrade Resend #3170
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
WalkthroughThe Changes
Estimated code review effortπ― 2 (Simple) | β±οΈ ~8 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touchesβ Failed checks (1 inconclusive)
β Passed checks (2 passed)
β¨ 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
π§Ή Nitpick comments (1)
packages/email/src/send-via-resend.ts (1)
53-55: Consider throwing instead of silently sending empty emails.The fallback to
text: ""could mask bugs by sending emails with empty bodies. If this "shouldn't happen in practice," failing early would help catch misuse during development.- // If none of react, html, or text is provided, we need to ensure at least one is present - // This shouldn't happen in practice, but we'll default to an empty text - return { ...baseOptions, text: "" }; + // This shouldn't happen - fail early to catch misuse + throw new Error("Email must have at least one of: react, html, or text");
π Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π Files selected for processing (1)
packages/email/src/send-via-resend.ts(3 hunks)
π§° Additional context used
π§ Learnings (1)
π Learning: 2025-09-12T21:08:43.990Z
Learnt from: TWilson023
Repo: dubinc/dub PR: 2835
File: apps/web/ui/analytics/feedback/action.ts:10-13
Timestamp: 2025-09-12T21:08:43.990Z
Learning: In the Dub email system, sendViaNodeMailer is intentionally designed as a simple backup mechanism with hard-coded sender fields, not as a full-featured email sender that preserves all metadata like from/replyTo fields. The primary email path uses Resend for full functionality.
Applied to files:
packages/email/src/send-via-resend.ts
𧬠Code graph analysis (1)
packages/email/src/send-via-resend.ts (2)
packages/email/src/resend/types.ts (1)
ResendEmailOptions(3-8)packages/email/src/resend/constants.ts (1)
VARIANT_TO_FROM_MAP(3-7)
π Additional comments (4)
packages/email/src/send-via-resend.ts (4)
1-1: LGTM!Good use of
import typefor type-only imports, which improves tree-shaking and makes the intent clear.
6-8: LGTM!Explicit return type annotation improves type safety and serves as documentation for consumers of this function.
42-42: LGTM!Clean conditional spreading pattern that avoids including empty or undefined headers.
28-28: Non-null assertion onsubjectmay mask missing subjects.The
subject!assertion bypasses TypeScript's null checks. If a caller accidentally omitssubject, this will silently pass the undefined value to Resend, potentially causing API errors or sending emails without subjects.Consider either:
- Validating
subjectat runtime with a guard- Making
subjectrequired inResendEmailOptionsif it should always be present- subject: subject!, + subject: subject ?? "",Or add validation:
if (!subject) { throw new Error("Email subject is required"); }β Skipped due to learnings
Learnt from: devkiran Repo: dubinc/dub PR: 3113 File: apps/web/app/(ee)/api/cron/payouts/charge-succeeded/send-paypal-payouts.ts:65-75 Timestamp: 2025-11-17T05:19:11.972Z Learning: In the Dub codebase, `sendBatchEmail` (implemented in packages/email/src/send-via-resend.ts) handles filtering of emails with invalid `to` addresses internally. Call sites can safely use non-null assertions on email addresses because the email sending layer will filter out any entries with null/undefined `to` values before sending. This centralized validation pattern is intentional and removes the need for filtering at individual call sites.
Summary by CodeRabbit
Bug Fixes
Refactor
βοΈ Tip: You can customize this high-level summary in your review settings.