diff --git a/src/backend/middlewares/RenderingMWs.ts b/src/backend/middlewares/RenderingMWs.ts index 898b375d..f4022dab 100644 --- a/src/backend/middlewares/RenderingMWs.ts +++ b/src/backend/middlewares/RenderingMWs.ts @@ -111,13 +111,15 @@ export class RenderingMWs { const originalConf = await ExtensionConfigWrapper.original(); // These are sensitive information, do not send to the client side originalConf.Server.sessionSecret = null; + const originalConfJSON = JSON.parse(JSON.stringify(originalConf.toJSON({ + attachState: true, + attachVolatile: true, + skipTags: {secret: true} as TAGS + }) as PrivateConfigClass)); + const message = new Message( null, - originalConf.toJSON({ - attachState: true, - attachVolatile: true, - skipTags: {secret: true} as TAGS - }) as PrivateConfigClass + originalConfJSON ); res.json(message); } diff --git a/src/backend/model/extension/ExtensionConfigWrapper.ts b/src/backend/model/extension/ExtensionConfigWrapper.ts index ac2e72e4..eaa7270f 100644 --- a/src/backend/model/extension/ExtensionConfigWrapper.ts +++ b/src/backend/model/extension/ExtensionConfigWrapper.ts @@ -12,17 +12,17 @@ const LOG_TAG = '[ExtensionConfigWrapper]'; */ export class ExtensionConfigWrapper { - static async original(showError = false): Promise { + static async original(showDetailedError = false): Promise { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc); try { await pc.load(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { - if(showError){ - console.error(LOG_TAG,'Error during loading config. Reverting to defaults.'); - console.error(LOG_TAG,'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); - console.error(e); + console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.'); + console.error(e); + if (showDetailedError) { + console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); NotificationManager.error('Can\'t load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e))); } } @@ -30,17 +30,17 @@ export class ExtensionConfigWrapper { } - static originalSync(showError = false): PrivateConfigClass & IConfigClass { + static originalSync(showDetailedError = false): PrivateConfigClass & IConfigClass { const pc = ConfigClassBuilder.attachPrivateInterface(new PrivateConfigClass()); ExtensionConfigTemplateLoader.Instance.loadExtensionTemplates(pc); try { pc.loadSync(); // loading the basic configs, but we do not know the extension config hierarchy yet } catch (e) { - if(showError){ - console.error(LOG_TAG,'Error during loading config. Reverting to defaults.'); - console.error(LOG_TAG,'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); - console.error(e); + console.error(LOG_TAG, 'Error during loading config. Reverting to defaults.'); + console.error(e); + if (showDetailedError) { + console.error(LOG_TAG, 'This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.'); NotificationManager.error('Ca\'nt load config. Reverting to default. This is most likely due to: 1) you added a bad configuration in the server.json OR 2) The configuration changed in the latest release.', (e.toString ? e.toString() : JSON.stringify(e))); } } diff --git a/test/backend/integration/routers/admin/SettingsRouter.ts b/test/backend/integration/routers/admin/SettingsRouter.ts index c57c5b37..a8ba8bf3 100644 --- a/test/backend/integration/routers/admin/SettingsRouter.ts +++ b/test/backend/integration/routers/admin/SettingsRouter.ts @@ -41,6 +41,13 @@ describe('SettingsRouter', () => { Config.Users.unAuthenticatedUserRole = UserRoles.Admin; const originalSettings = await ExtensionConfigWrapper.original(); + originalSettings.Environment.upTime = null; + const originalJSON = JSON.parse(JSON.stringify(originalSettings.toJSON({ + attachState: true, + attachVolatile: true, + skipTags: {secret: true} as TAGS + }))); + const result = await chai.request(server.Server) .get(Config.Server.apiPath + '/settings'); @@ -48,12 +55,7 @@ describe('SettingsRouter', () => { result.body.should.be.a('object'); should.equal(result.body.error, null); (result.body.result as ServerConfig).Environment.upTime = null; - originalSettings.Environment.upTime = null; - result.body.result.should.deep.equal(JSON.parse(JSON.stringify(originalSettings.toJSON({ - attachState: true, - attachVolatile: true, - skipTags: {secret: true} as TAGS - })))); + result.body.result.should.deep.equal(originalJSON); }); }); });