0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-06 22:40:14 -05:00

Removed 500 error during production boot \w a theme error

refs https://github.com/TryGhost/Team/issues/781
refs 813d288eb2#

- The 500 error was introduced through a refed commit long time ago when (probably?) there were no other safeguards preventing from serving content through a theme with errors. Since than we have multiple safeguards when aploading/activating the theme with errors and the default handling when such error occurs is more graceful - a 400 with specific error details is shown
- We need this change to land before bumping gscan that introduces more suphisticated error detaction in theme templates. Otherwise, people upgrading to new version and having an error on an unused template or somewhere undetected previously woul end up with a bricked site showing a generic 500 - not a great experience!
This commit is contained in:
Naz 2021-07-02 14:31:21 +04:00
parent 3ca4cd99f1
commit 076ad99593

View file

@ -1,7 +1,6 @@
const _ = require('lodash');
const hbs = require('./engine');
const urlUtils = require('../../../shared/url-utils');
const config = require('../../../shared/config');
const {i18n, api} = require('../proxy');
const errors = require('@tryghost/errors');
const settingsCache = require('../../../shared/settings-cache');
@ -24,16 +23,6 @@ function ensureActiveTheme(req, res, next) {
}));
}
// CASE: bootstrap theme validation failed, we would like to show the errors on the site [only production]
if (activeTheme.get().error && config.get('env') === 'production') {
return next(new errors.InternalServerError({
// We use the settingsCache here, because the setting will be set,
// even if the theme itself is not usable because it is invalid or missing.
message: i18n.t('errors.middleware.themehandler.invalidTheme', {theme: settingsCache.get('active_theme')}),
errorDetails: activeTheme.get().error.errorDetails
}));
}
// If the active theme has not yet been mounted, mount it into express
if (!activeTheme.get().mounted) {
activeTheme.get().mount(req.app);