Error details not being passed to the error message since migration to SDK JS v3 for AWS SES
See original GitHub issueDescribe the bug
The details of the error message are not being passed to the error message in AWS SDK JS v2 vs. v3.
Your environment
SDK version number
@aws-sdk/client-ses@3.13.1
comparing with @aws-sdk@2.897.0
Is the issue in the browser/Node.js/ReactNative?
Node.js
Details of the browser/Node.js/ReactNative version
Can’t check.
Steps to reproduce
- Configure AWS SES and verify the identity you wish to send a test email in a given region
- Implement the following code (SDK V3)
const {
SES
} = require('@aws-sdk/client-ses');
async callback => {
function generateParams() {
...
return params
}
function sendingEmail(bufferedData) {
return new Promise((resolve, reject) => {
const creds = {
accessKeyId: keys["Key"],
secretAccessKey: keys["Key Secret"],
};
const ses = new SES({
apiVersion: '2010-12-01',
region: keys["AWS Service Endpoint Region"] || 'us-east-1',
credentials: creds
});
ses.sendEmail(bufferedData, function(error, data) {
if (error) {
reject(error);
} else {
return resolve(data.MessageId);
};
});
});
}
generateParam()
.then(
(bufferedData) => {
sendingEmail(bufferedData)
.then(
(dataFromSes) => {
callback(undefined, dataFromSes);
})
.catch(
(err) => {
callback(err);
})
})
.catch(
(err) => {
callback(err);
});
}
- Change the region by another one on which your identities are not verified to trigger a SDK error.
- The error message says
MessageRejected: MessageRejected
- Now compare with SDK V2 implementation.
const AWS = require('aws-sdk');
async callback => {
function generateParams() {
...
return params
}
function sendingEmail(bufferedData) {
return new Promise((resolve, reject) => {
const ses = new AWS.SES({
apiVersion: '2010-12-01',
accessKeyId: keys["Key"],
secretAccessKey: keys["Key Secret"],
region: keys["AWS Service Endpoint Region"] || 'us-east-1'
});
ses.sendEmail(bufferedData, function(error, data) {
if (error) {
reject(error);
} else {
return resolve(data.MessageId);
};
});
});
}
generateParam()
.then(
(bufferedData) => {
sendingEmail(bufferedData)
.then(
(dataFromSes) => {
callback(undefined, dataFromSes);
})
.catch(
(err) => {
callback(err);
})
})
.catch(
(err) => {
callback(err);
});
}
- The error message says
MessageRejected: Email address is not verified. The following identities failed the check in region US-EAST-2.
Observed behavior
The message does not give any details of why it occurred.
MessageRejected: MessageRejected
at deserializeAws_querySendEmailCommandError (/var/task/node_modules/@aws-sdk/client-ses/dist/cjs/protocols/Aws_query.js:3368:41)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
at async /var/task/node_modules/@aws-sdk/middleware-serde/dist/cjs/deserializerMiddleware.js:6:20
at async /var/task/node_modules/@aws-sdk/middleware-signing/dist/cjs/middleware.js:12:24
at async StandardRetryStrategy.retry (/var/task/node_modules/@aws-sdk/middleware-retry/dist/cjs/defaultStrategy.js:56:46)
at async /var/task/node_modules/@aws-sdk/middleware-logger/dist/cjs/loggerMiddleware.js:6:22
Expected behavior
The full error message detail should be passed to the error description.
MessageRejected: Email address is not verified. The following identities failed the check in region US-EAST-2: xxx@domain.com
at Request.extractError (/var/task/node_modules/aws-sdk/lib/protocol/query.js:50:29)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:688:14)
at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)
at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)
at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:38:9)
at Request.<anonymous> (/var/task/node_modules/aws-sdk/lib/request.js:690:12)
at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
Additional context
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Error Handling in Modular AWS SDK for JavaScript (v3)
In this post, we cover how to use it and how it improves the error handling experience. Why did we do it? Previously,...
Read more >AWS SDK for JavaScript v3
Let's walk through setting up a project that depends on DynamoDB from the SDK and makes a simple service call. The following steps...
Read more >Sending email using Amazon SES - AWS SDK for JavaScript
This Node.js code example shows: Send a text or HTML email. Send emails based on an email template.
Read more >SES Client - AWS SDK for JavaScript v3
AWS SDK for JavaScript SES Client for Node.js, Browser and React Native. Amazon Simple Email Service. This document contains reference information for the ......
Read more >Class: AWS.SES — AWS SDK for JavaScript
Constructs a service interface object. Each API operation is exposed as a function on service. Service Description.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Was able to reproduce it and seems to be deserialization issue at first, will post a fix soon.
https://github.com/aws/aws-sdk-js-v3/blob/fac5f27fc2727d91be49e403a1a81005efe685d6/clients/client-ses/protocols/Aws_query.ts#L9490
Capital case
Message
should also be taken care of.Het there! Has a fix been pushed?