-
Notifications
You must be signed in to change notification settings - Fork 586
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
SESv2 SendBulkEmailCommand: Template contains unsupported operations #6657
Comments
Hi @BabyDino , You are using the wrong API. the docs you linked was for the legacy SES client and not the newer SESv2 client which you are attempting to use in your repro code. AFAIK SESv2 does not support conditional statements using handlebars. You can use SES's (v1) import { SESClient, CreateTemplateCommand, SendBulkTemplatedEmailCommand } from "@aws-sdk/client-ses";
const sesClient = new SESClient({ region: "us-east-1" });
try {
await sesClient.send(new CreateTemplateCommand({
Template: {
TemplateName: "MyTemplate",
SubjectPart: "Hello world!",
TextPart: "Dear {{#if firstName}} {{firstName}}{{/if}}",
HtmlPart: "<html>Dear {{#if firstName}} {{firstName}}{{/if}}</html>"
}
}));
const response = await sesClient.send(new SendBulkTemplatedEmailCommand({
Source: "[email protected]",
Template: "MyTemplate",
Destinations: [{
Destination: {
ToAddresses: ["[email protected]"],
},
ReplacementTemplateData: JSON.stringify({ firstName: "Joe" })
}],
DefaultTemplateData: JSON.stringify({ firstName: "" })
}));
console.log(response);
} catch (err) {
console.error(err);
} Thanks, |
Hi @RanVaknin, This is the link to the docs regarding inline templates: https://docs.aws.amazon.com/ses/latest/dg/send-personalized-email-api.html#send-personalized-email-api-operations. The variables work for inline templating on SESv2, but the conditional statements do not. These do work in the example you've provided, but the whole idea of this update was the removal of the requirement for creating a template first (as announced here). I just ran the 'Inline template code example' using the AWS CLI, and unfortunately I get the same error on SESv2 using the CLI. So I do agree this is not an issue with this SDK, but rather a higher level API one. Since I am unsure now if this is by design, can you point me to the spot where I can raise another issue? Many thanks! |
Hi @BabyDino , Thanks for the clarification. I agree, this seems like a bug with the service itself. I have created an internal ticket with the SES service team (ticket ID |
Hi @BabyDino , I heard back from the service team:
https://docs.aws.amazon.com/ses/latest/dg/send-personalized-email-api.html
Inline templates do not support conditional statements. I have requested that the service team add some clarifications to their docs about it for future use. Thanks, |
I encountered the same problem, even though I wasn't using conditional statements. After some debugging, I discovered that the issue was caused by using snake_case variables in the inline template. Initially, I had |
Feel free to leave documentation feedback directly with the SES service team here. |
This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs and link to relevant comments in this thread. |
Checkboxes for prior research
Describe the bug
When using the
SendBulkEmailCommand
with in-line templates, Handlebars conditional statements are not accepted by the SDK.{{#if var}}{{var}}{{/if}}
throws a BadRequestException:Regression Issue
SDK version number
@aws-sdk/client-sesv2@latest
Which JavaScript Runtime is this issue in?
Node.js
Details of the browser/Node.js/ReactNative version
v20.17.0
Reproduction Steps
throws the following exception:
Using
#if
conditional statements is supported, according to the official docs.Observed Behavior
Expected Behavior
Expect the template to send. In case of renderfailures, this is by the configuration set.
Possible Solution
No response
Additional Information/Context
No response
The text was updated successfully, but these errors were encountered: