question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error details not being passed to the error message since migration to SDK JS v3 for AWS SES

See original GitHub issue

Describe 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

  1. Configure AWS SES and verify the identity you wish to send a test email in a given region
  2. 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);
            });
}
  1. Change the region by another one on which your identities are not verified to trigger a SDK error.
  2. The error message says MessageRejected: MessageRejected
  3. 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);
            });
}
  1. 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

Perhaps related to #2261, #1287

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

4reactions
ajredniwjacommented, Aug 18, 2021

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.

0reactions
redvivicommented, Mar 17, 2022

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.

Same Problem. Could you push your fix and create a new release?

Het there! Has a fix been pushed?

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found