From 1086a7bbc105b0d7dffa2589cb03543f7aa4aa66 Mon Sep 17 00:00:00 2001 From: "posthog[bot]" <206114724+posthog[bot]@users.noreply.github.com> Date: Tue, 30 Jun 2026 14:32:32 +0000 Subject: [PATCH] fix(sveltekit-mailer): guard new Resend() against missing API key sendAdminEmail constructed `new Resend(env.PRIVATE_RESEND_API_KEY)` without first checking the key was set. When PRIVATE_RESEND_API_KEY is absent, the Resend SDK throws at construction time, turning a missing optional config into an error. Add the same early-return guard that sendTemplatedEmail already uses, so the admin email is skipped gracefully when email isn't configured. Generated-By: PostHog Code Task-Id: 9ce4855b-4902-42ed-8c1d-650d7eaeb516 --- .../sveltekit/CMSaasStarter/src/lib/mailer.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/basic-integration/sveltekit/CMSaasStarter/src/lib/mailer.ts b/apps/basic-integration/sveltekit/CMSaasStarter/src/lib/mailer.ts index ad6576653..ba3f0d3e8 100644 --- a/apps/basic-integration/sveltekit/CMSaasStarter/src/lib/mailer.ts +++ b/apps/basic-integration/sveltekit/CMSaasStarter/src/lib/mailer.ts @@ -20,6 +20,11 @@ export const sendAdminEmail = async ({ return } + if (!env.PRIVATE_RESEND_API_KEY) { + // email not configured. Emails are optional so no error is thrown + return + } + try { const resend = new Resend(env.PRIVATE_RESEND_API_KEY) const resp = await resend.emails.send({