-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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 error message code for HB translate helper #15529
🐛 fixed error message code for HB translate helper #15529
Conversation
closes TryGhost#15500 Per the issue, Ghost has a policy to never throw 500 Internal Server errors for theme issues. This change adds a check inside of `ghost\core\core\frontend\helpers\t.js` if `text` or `options` is undefined, to throw an `IncorrectUsageError` error within the function. Messaging was borrowed from `ghost\core\core\frontend\web\middleware\error-handler.js`.
Codecov ReportBase: 52.91% // Head: 52.89% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #15529 +/- ##
==========================================
- Coverage 52.91% 52.89% -0.02%
==========================================
Files 1378 1378
Lines 89183 89195 +12
Branches 9560 9563 +3
==========================================
- Hits 47187 47184 -3
- Misses 41048 41059 +11
- Partials 948 952 +4
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
Hi @cweave thanks so much for this PR and I'm sorry for taking so long to review it - we got a bit inundated. The PR has now been merged 🎉 and will appear in the next release of Ghost - usually Fridays. I'm not sure if you found this through hacktoberfest, but I've added the accepted label to this PR to make sure it counts. If you'd like to take this further, I'd love to see a unit test added here for the underlying bug to ensure this can't happen again. |
Thanks, @ErisDS ! I did indeed find it via Hacktoberfest. I'll take a look at unit testing as well |
Added unit tests to the MR TryGhost#15529 / issue TryGhost#15500. Added a regex in the `t()` to explicitly check for smart apostrophes in the event that they are not stripped out/come through as undefined.
closes: #15500 - Per the issue, Ghost has a policy to never throw 500 Internal Server errors for theme issues. This change adds a check inside of `ghost\core\core\frontend\helpers\t.js` if `text` or `options` is undefined, to throw an `IncorrectUsageError` error within the function. - Messaging was borrowed from `ghost\core\core\frontend\web\middleware\error-handler.js`.
Got some code for us? Awesome 🎊!
Please include a description of your change & check your PR against this list, thanks!
#15500 - Ghost has a policy to never throw 500 Internal Server errors for theme issues. Updated error handing to return a 400 error and a better error message "Oops, seems there is an error in the template."
This change adds a check inside of
ghost\core\core\frontend\helpers\t.js
iftext
oroptions
is undefined, to throw anIncorrectUsageError
error within the function.Messaging was borrowed from
ghost\core\core\frontend\web\middleware\error-handler.js
.Steps to Reproduce
Ghost Version
5.17.x
I know the original issue stated v4.42.1, but I was consistently able to reproduce the issue in this version as well. If there is a need for that version as well, I am happy to investigate that as well.
When
{{t “This causes an error”})
is used,text
is coming into thet()
function as undefined. I'm using Windows - unsure if that's causing something different as well, since someone else reported it was working fine in the issue.yarn test:all
andyarn lint
)We appreciate your contribution!
Also, if you'd be interested in writing code like this for us more regularly, we're hiring:
https://careers.ghost.org