Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 Fixed newsletter not sending if locale is invalid #21573

Merged
merged 1 commit into from
Nov 7, 2024
Merged

Conversation

ErisDS
Copy link
Member

@ErisDS ErisDS commented Nov 7, 2024

ref https://github.com/moment/luxon/blob/master/docs/intl.md

  • We noticed the following error trace: RangeError: Incorrect locale information provided
    at BatchSendingService.retryDb (/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:639:32)
    at new DateTimeFormat ()
    at getCachedDTF (/home/ghost/node_modules/luxon/build/node/luxon.js:621:11)
    at new PolyDateFormatter (/home/ghost/node_modules/luxon/build/node/luxon.js:842:16)
    at Locale.dtFormatter (/home/ghost/node_modules/luxon/build/node/luxon.js:1066:12)
    at Formatter.dtFormatter (/home/ghost/node_modules/luxon/build/node/luxon.js:2274:21)
    at Formatter.formatDateTime (/home/ghost/node_modules/luxon/build/node/luxon.js:2280:17)
    at DateTime.toLocaleString (/home/ghost/node_modules/luxon/build/node/luxon.js:6893:78)
    at formatDateLong (/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:45:74)
    at Object.getValue (/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:683:47)
    at /home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:158:36
    at Array.map ()
    at /home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:154:54
    at Array.map ()
    at SendingService.buildRecipients (/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:151:24)
    at SendingService.send (/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:127:33)
    at response.retryDb (/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:451:51)
  • This is due to the locale being user-input - it can be set to any string.
  • In our email sending code we pass the string to luxon to format dates, which errors if the locale is not valid according it Intl.
  • This fix ensures that the locale is valid before passing it to luxon, falling back to en-gb if the locale is not valid

closes: https://linear.app/ghost/issue/ENG-1752
ref https://github.com/moment/luxon/blob/master/docs/intl.md

- We noticed the following error trace:
RangeError: Incorrect locale information provided
    at BatchSendingService.retryDb (/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:639:32)
    at new DateTimeFormat (<anonymous>)
    at getCachedDTF (/home/ghost/node_modules/luxon/build/node/luxon.js:621:11)
    at new PolyDateFormatter (/home/ghost/node_modules/luxon/build/node/luxon.js:842:16)
    at Locale.dtFormatter (/home/ghost/node_modules/luxon/build/node/luxon.js:1066:12)
    at Formatter.dtFormatter (/home/ghost/node_modules/luxon/build/node/luxon.js:2274:21)
    at Formatter.formatDateTime (/home/ghost/node_modules/luxon/build/node/luxon.js:2280:17)
    at DateTime.toLocaleString (/home/ghost/node_modules/luxon/build/node/luxon.js:6893:78)
    at formatDateLong (/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:45:74)
    at Object.getValue (/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:683:47)
    at /home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:158:36
    at Array.map (<anonymous>)
    at /home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:154:54
    at Array.map (<anonymous>)
    at SendingService.buildRecipients (/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:151:24)
    at SendingService.send (/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:127:33)
    at response.retryDb (/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:451:51)
- This is due to the locale being user-input - it can be set to any string.
- In our email sending code we pass the string to luxon to format dates, which errors if the locale is not valid according it Intl.
- This fix ensures that the locale is valid before passing it to luxon, falling back to en-gb if the locale is not valid
@ErisDS ErisDS merged commit d3cda0d into main Nov 7, 2024
21 checks passed
@ErisDS ErisDS deleted the locale-email-fix branch November 7, 2024 21:55
9larsons pushed a commit that referenced this pull request Nov 7, 2024
ref https://github.com/moment/luxon/blob/master/docs/intl.md

- We noticed the following error trace: RangeError: Incorrect locale
information provided
at BatchSendingService.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:639:32)
    at new DateTimeFormat (<anonymous>)
at getCachedDTF
(/home/ghost/node_modules/luxon/build/node/luxon.js:621:11)
at new PolyDateFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:842:16)
at Locale.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:1066:12)
at Formatter.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:2274:21)
at Formatter.formatDateTime
(/home/ghost/node_modules/luxon/build/node/luxon.js:2280:17)
at DateTime.toLocaleString
(/home/ghost/node_modules/luxon/build/node/luxon.js:6893:78)
at formatDateLong
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:45:74)
at Object.getValue
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:683:47)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:158:36
    at Array.map (<anonymous>)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:154:54
    at Array.map (<anonymous>)
at SendingService.buildRecipients
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:151:24)
at SendingService.send
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:127:33)
at response.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:451:51)
- This is due to the locale being user-input - it can be set to any
string.
- In our email sending code we pass the string to luxon to format dates,
which errors if the locale is not valid according it Intl.
- This fix ensures that the locale is valid before passing it to luxon,
falling back to en-gb if the locale is not valid
ErisDS added a commit that referenced this pull request Nov 7, 2024
ref #21573

- We discussed this, and figured we should get this behind the flag for now, even though it's pulled
- This gives us the ability to do a fast revert if we have to later, which is the point of having the labs "GA FEATURES" array
- Note this removes the labsEnabled variable in the tests to make it clearer if the flag is off or on (it was off!)
9larsons pushed a commit that referenced this pull request Nov 7, 2024
ref https://github.com/moment/luxon/blob/master/docs/intl.md

- We noticed the following error trace: RangeError: Incorrect locale
information provided
at BatchSendingService.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:639:32)
    at new DateTimeFormat (<anonymous>)
at getCachedDTF
(/home/ghost/node_modules/luxon/build/node/luxon.js:621:11)
at new PolyDateFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:842:16)
at Locale.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:1066:12)
at Formatter.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:2274:21)
at Formatter.formatDateTime
(/home/ghost/node_modules/luxon/build/node/luxon.js:2280:17)
at DateTime.toLocaleString
(/home/ghost/node_modules/luxon/build/node/luxon.js:6893:78)
at formatDateLong
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:45:74)
at Object.getValue
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:683:47)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:158:36
    at Array.map (<anonymous>)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:154:54
    at Array.map (<anonymous>)
at SendingService.buildRecipients
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:151:24)
at SendingService.send
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:127:33)
at response.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:451:51)
- This is due to the locale being user-input - it can be set to any
string.
- In our email sending code we pass the string to luxon to format dates,
which errors if the locale is not valid according it Intl.
- This fix ensures that the locale is valid before passing it to luxon,
falling back to en-gb if the locale is not valid
9larsons pushed a commit that referenced this pull request Nov 7, 2024
ref #21573

- We discussed this, and figured we should get this behind the flag for
now, even though it's pulled
- This gives us the ability to do a fast revert if we have to later,
which is the point of having the labs "GA FEATURES" array
- Note this removes the labsEnabled variable in the tests to make it
clearer if the flag is off or on (it was off!)
9larsons pushed a commit that referenced this pull request Nov 7, 2024
ref #21573

- We discussed this, and figured we should get this behind the flag for
now, even though it's pulled
- This gives us the ability to do a fast revert if we have to later,
which is the point of having the labs "GA FEATURES" array
- Note this removes the labsEnabled variable in the tests to make it
clearer if the flag is off or on (it was off!)
9larsons pushed a commit that referenced this pull request Nov 7, 2024
ref #21573

- We discussed this, and figured we should get this behind the flag for
now, even though it's pulled
- This gives us the ability to do a fast revert if we have to later,
which is the point of having the labs "GA FEATURES" array
- Note this removes the labsEnabled variable in the tests to make it
clearer if the flag is off or on (it was off!)
9larsons pushed a commit that referenced this pull request Nov 13, 2024
ref https://github.com/moment/luxon/blob/master/docs/intl.md

- We noticed the following error trace: RangeError: Incorrect locale
information provided
at BatchSendingService.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:639:32)
    at new DateTimeFormat (<anonymous>)
at getCachedDTF
(/home/ghost/node_modules/luxon/build/node/luxon.js:621:11)
at new PolyDateFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:842:16)
at Locale.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:1066:12)
at Formatter.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:2274:21)
at Formatter.formatDateTime
(/home/ghost/node_modules/luxon/build/node/luxon.js:2280:17)
at DateTime.toLocaleString
(/home/ghost/node_modules/luxon/build/node/luxon.js:6893:78)
at formatDateLong
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:45:74)
at Object.getValue
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:683:47)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:158:36
    at Array.map (<anonymous>)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:154:54
    at Array.map (<anonymous>)
at SendingService.buildRecipients
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:151:24)
at SendingService.send
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:127:33)
at response.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:451:51)
- This is due to the locale being user-input - it can be set to any
string.
- In our email sending code we pass the string to luxon to format dates,
which errors if the locale is not valid according it Intl.
- This fix ensures that the locale is valid before passing it to luxon,
falling back to en-gb if the locale is not valid
9larsons pushed a commit that referenced this pull request Nov 13, 2024
ref #21573

- We discussed this, and figured we should get this behind the flag for
now, even though it's pulled
- This gives us the ability to do a fast revert if we have to later,
which is the point of having the labs "GA FEATURES" array
- Note this removes the labsEnabled variable in the tests to make it
clearer if the flag is off or on (it was off!)
tilak999 pushed a commit to tilak999/ghost that referenced this pull request Nov 20, 2024
ref https://github.com/moment/luxon/blob/master/docs/intl.md

- We noticed the following error trace: RangeError: Incorrect locale
information provided
at BatchSendingService.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:639:32)
    at new DateTimeFormat (<anonymous>)
at getCachedDTF
(/home/ghost/node_modules/luxon/build/node/luxon.js:621:11)
at new PolyDateFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:842:16)
at Locale.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:1066:12)
at Formatter.dtFormatter
(/home/ghost/node_modules/luxon/build/node/luxon.js:2274:21)
at Formatter.formatDateTime
(/home/ghost/node_modules/luxon/build/node/luxon.js:2280:17)
at DateTime.toLocaleString
(/home/ghost/node_modules/luxon/build/node/luxon.js:6893:78)
at formatDateLong
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:45:74)
at Object.getValue
(/home/ghost/node_modules/@tryghost/email-service/lib/EmailRenderer.js:683:47)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:158:36
    at Array.map (<anonymous>)
at
/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:154:54
    at Array.map (<anonymous>)
at SendingService.buildRecipients
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:151:24)
at SendingService.send
(/home/ghost/node_modules/@tryghost/email-service/lib/SendingService.js:127:33)
at response.retryDb
(/home/ghost/node_modules/@tryghost/email-service/lib/BatchSendingService.js:451:51)
- This is due to the locale being user-input - it can be set to any
string.
- In our email sending code we pass the string to luxon to format dates,
which errors if the locale is not valid according it Intl.
- This fix ensures that the locale is valid before passing it to luxon,
falling back to en-gb if the locale is not valid
tilak999 pushed a commit to tilak999/ghost that referenced this pull request Nov 20, 2024
ref TryGhost#21573

- We discussed this, and figured we should get this behind the flag for
now, even though it's pulled
- This gives us the ability to do a fast revert if we have to later,
which is the point of having the labs "GA FEATURES" array
- Note this removes the labsEnabled variable in the tests to make it
clearer if the flag is off or on (it was off!)
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.

1 participant