From 7ffee524082a6fac71bf11d95452c8c63de24620 Mon Sep 17 00:00:00 2001 From: Till-JS <101404291+Till-JS@users.noreply.github.com> Date: Thu, 29 Jan 2026 23:25:46 +0100 Subject: [PATCH] fix(notify-client): don't send undefined emailOptions Only include emailOptions object when from or replyTo is provided, preventing validation errors when these optional fields are not set. Co-Authored-By: Claude Opus 4.5 --- packages/notify-client/src/client.ts | 36 ++++++++++++++++++---------- 1 file changed, 24 insertions(+), 12 deletions(-) diff --git a/packages/notify-client/src/client.ts b/packages/notify-client/src/client.ts index 3ae108c61..674bf2592 100644 --- a/packages/notify-client/src/client.ts +++ b/packages/notify-client/src/client.ts @@ -36,7 +36,7 @@ export class NotifyClient { * Send an email notification */ async sendEmail(options: SendEmailOptions): Promise { - return this.send({ + const payload: Record = { channel: 'email', appId: this.appId, recipient: options.to, @@ -44,13 +44,19 @@ export class NotifyClient { subject: options.subject, body: options.body, data: options.data, - emailOptions: { - from: options.from, - replyTo: options.replyTo, - }, priority: options.priority, externalId: options.externalId, - }); + }; + + // Only include emailOptions if from or replyTo is provided + if (options.from || options.replyTo) { + payload.emailOptions = { + ...(options.from && { from: options.from }), + ...(options.replyTo && { replyTo: options.replyTo }), + }; + } + + return this.send(payload); } /** @@ -117,7 +123,7 @@ export class NotifyClient { * Schedule an email notification */ async scheduleEmail(options: SendEmailOptions & ScheduleOptions): Promise { - return this.schedule({ + const payload: Record = { channel: 'email', appId: this.appId, recipient: options.to, @@ -125,17 +131,23 @@ export class NotifyClient { subject: options.subject, body: options.body, data: options.data, - emailOptions: { - from: options.from, - replyTo: options.replyTo, - }, priority: options.priority, externalId: options.externalId, scheduledFor: options.scheduledFor instanceof Date ? options.scheduledFor.toISOString() : options.scheduledFor, - }); + }; + + // Only include emailOptions if from or replyTo is provided + if (options.from || options.replyTo) { + payload.emailOptions = { + ...(options.from && { from: options.from }), + ...(options.replyTo && { replyTo: options.replyTo }), + }; + } + + return this.schedule(payload); } /**