aws / aws/aws-lambda-go

Cognito Custom Message Trigger Failing Regex

Open
#330 0 comments 0 reactions 0 assignees View on GitHub
troubleshooting
Dominant language
Go
Stars
3.8k
Forks
578
Avg merge
8h 18m
Merged PRs (30d)
1

Description

I am unable to send custom html message for CustomMessage_ForgotPassword events. Both events follow the same code path and do the same escaping. The `EmailMessage` prints out correctly however I see the following message returned in the front-end when trying to send a code for resetting password:
```
1 validation error detected: Value ' Your verification code body { font-family: "SF Pro Display", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, "Open Sans", "Helvetica Neue", sans-serif; font-size: 15px; line-height: 1.4; color: #3c4149; background: #fff } a { color: #2161dc; text-decoration: none } p { margin-top: 0; margin-bottom: 6px } blockquote { margin: 0; font-style: italic } @media screen and (max-width:600px) { p img { object-fit: contain; max-height: 500px; width: 100% } #main { border: 0 !important; padding: 0 !important; box-shadow: none !important; margin: 0 !important } } #__bodyTable__ { margin: 0; padding: 0; width: 100% !important; } logo

Your verification code


Hi Oct22 No Company, Your verification code is below and will expire in 24 hours. (userId: ) CODE: {####} Local Test ' at 'emailBody' failed to satisfy constraint: Member must satisfy regular expression pattern: [\p{L}\p{M}\p{S}\p{N}\p{P}\s*]*\{####\}[\p{L}\p{M}\p{S}\p{N}\p{P}\s*]*
```

The implementation to generate this value is pretty straightforward. Following this same implementation but
```
t, err := template.New("email_template").Parse(parsingTemplate)
if err != nil {
return "", err
}
var body bytes.Buffer
if err := t.Execute(&body, data); err != nil {
return "", err
}
htmlBody := body.String()
htmlBody = html.UnescapeString(htmlBody)
event.Response.EmailMessage = htmlBody
```
The parsing template is based on an html template file. Here is the file:
[verification_code_email_template.txt](https://github.com/aws/aws-lambda-go/files/5446935/verification_code_email_template.txt). Using .txt extension to share on github otherwise it is .html.

Following the same implementation I can successfully send email for other event types such as CustomMessage_AdminCreateUser.

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.