Skip to content

Conversation

ivannovosad
Copy link
Contributor

Context

Some mailer jobs fail because the recipient email is invalid.
It is due to the email validator bug in case of multiple comma-separated emails, it was only validating the first one in the list.

This was considered to be valid even if the second email is invalid: email1@test-email.com, email2@test- email.com

Description

This PR fixes the email validator.

Copy link
Contributor

@ancorcruz ancorcruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ivannovosad ivannovosad force-pushed the fix-customer-email branch from 4d9bac4 to ef612d7 Compare June 5, 2025 08:17
@ivannovosad ivannovosad force-pushed the fix-customer-email branch 2 times, most recently from b16e262 to 822b4f9 Compare June 17, 2025 09:59
groyoh added a commit that referenced this pull request Jun 18, 2025
Our current email validation regex is too permissive, allowing invalid emails like `test email@domain.com`. This caused some invoice emails sendout failures.

The main issue comes from the fact that our regex does not have `\A` and `\z` anchors, which means it can match parts of a string rather than the whole string.

Another issue is that we allow `customers.email` to include multiple emails separated by commas, but our regex does not handle this correctly. The fix for this was copied from getlago/lago-api#3590.
Copy link
Contributor

@ancorcruz ancorcruz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

still LGTM!

@ivannovosad ivannovosad merged commit 5a82b6f into main Jun 25, 2025
14 checks passed
@ivannovosad ivannovosad deleted the fix-customer-email branch June 25, 2025 13:58
diegocharles pushed a commit that referenced this pull request Jun 30, 2025
## Context

Some mailer jobs fail because the recipient email is invalid.
It is due to the email validator bug in case of multiple comma-separated
emails, it was only validating the first one in the list.

This was considered to be valid even if the second email is invalid:
`email1@test-email.com, email2@test- email.com`

## Description

This PR fixes the email validator.
diegocharles pushed a commit that referenced this pull request Jul 11, 2025
## Context

Some mailer jobs fail because the recipient email is invalid.
It is due to the email validator bug in case of multiple comma-separated
emails, it was only validating the first one in the list.

This was considered to be valid even if the second email is invalid:
`email1@test-email.com, email2@test- email.com`

## Description

This PR fixes the email validator.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants