Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
TypeScript ai-agentsbill-of-materialserpinventory-managementleanmanufacturingmanufacturing-execution-systemmcp-servermesmrpopen-source-erppostgresqlproduction-planningqmsquality-management-systemreact-routerself-hostedsupabasetraceabilitytypescript
fix: filter null/undefined entries from email to/cc recipients
Claudefcdacca6153e
diff --git a/packages/jobs/src/inngest/functions/notifications/send-email.ts b/packages/jobs/src/inngest/functions/notifications/send-email.tsindex 6955a4b5a8..fde59eb5ed 100644--- a/packages/jobs/src/inngest/functions/notifications/send-email.ts+++ b/packages/jobs/src/inngest/functions/notifications/send-email.ts@@ -14,6 +14,30 @@ export const sendEmailFunction = inngest.createFunction(const payload = event.data;const serviceRole = getCarbonServiceRole();+ // Resend rejects the request if `to` or `cc` contain null/undefined+ // entries, so strip falsy values regardless of what callers pass.+ const sanitizeRecipients = (+ value: string | string[] | undefined+ ): string | string[] | undefined => {+ if (Array.isArray(value)) {+ const filtered = value.filter(+ (entry): entry is string =>+ typeof entry === "string" && entry.length > 0+ );+ return filtered.length ? filtered : undefined;+ }+ return value && typeof value === "string" ? value : undefined;+ };++ const toRecipients = sanitizeRecipients(payload.to);+ const ccRecipients = sanitizeRecipients(payload.cc);++ if (!toRecipients) {+ throw new NonRetriableError(+ "send-email called without any valid `to` recipients"+ );+ }+const { companyName, integrationMetadata, integrationActive } =await step.run("fetch-company-integration", async () => {const [companyResult, integrationResult] = await Promise.all([@@ -82,8 +106,8 @@ export const sendEmailFunction = inngest.createFunction(console.info(`SMTP Email Job`);return transporter.sendMail({from: fromAddress,- to: payload.to,- cc: payload.cc,+ to: toRecipients,+ cc: ccRecipients,replyTo: payload.from,subject: payload.subject,html: payload.html,@@ -106,8 +130,8 @@ export const sendEmailFunction = inngest.createFunction(const email = {from: fromAddress,- to: payload.to,- cc: payload.cc,+ to: toRecipients,+ cc: ccRecipients,reply_to: payload.from,subject: payload.subject,html: payload.html,