aws-amplify / aws-amplify/amplify-cli

Weird content of confirmation email triggered by Custom message Lambda trigger after creating new environment

Open
#9,701 16 comments 0 reactions 0 assignees View on GitHub
auth bug multienv p2
Dominant language
TypeScript
Stars
2.9k
Forks
825
Avg merge
11d 23h
Merged PRs (30d)
2

Description

### Before opening, please confirm:

- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
- [X] I have removed any sensitive information from my code snippets and submission.

### How did you install the Amplify CLI?

yarn

### If applicable, what version of Node.js are you using?

_No response_

### Amplify CLI Version

7.6.15

### What operating system are you using?

Mac

### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.

No manual changes

### Amplify Categories

auth, custom, storage, function, api

### Amplify Commands

push

### Describe the bug

The content of the email that should come with verification link is mixed.
By mixed I mean that sometimes the body of the email that is set in the lambda trigger is actually replaced by the default body that can be seen in the 'message templates' (verification message) in Messaging tab of user pool console, but the subject of the email is correct (set in lambda).
Other times the subject and the body of the email that should be set in lambda are replaced with the default ones. Probably because the variables that should contain appropriate strings (emailSubject, emailMessage) are empty - looks like the settings in `function-parameters.json` is ignored in this case.

At some point I was able to fix it, but to be honest I don't remember how, it suddenly started to work after several `amplify update auth` + `amplify push --force`... but few updates later (`amplify push`, deployment in amplify console and upgrade of amplify) broke this trigger. There are no errors in the cloudwatch...

### Expected behavior

Verification email contains a correct subject and the body set in custom message lambda trigger and settings in `function-parameters.json` are respected.

### Reproduction steps

1. Deploy app by CI/CD (amplify console)
2. Create a user (in the app) triggers the email with default subject and body (those set in lambda are emptied): https://d.pr/i/Ke6yfL
3. Update the code of the lambda trigger by adding a simple console.log
4. Push updates via `amplify push`
5. create another user triggers the email with this content: https://d.pr/i/nMMs94
6. Another deployment via CI/CD
7. create another user triggers the email with such content: https://d.pr/i/ifRNpE

### GraphQL schema(s)

```graphql
# Put schemas below this line

```

### Log output

```
# Put your logs below this line

```

### Additional information

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.