From 020cd05eab7b919518733018dfd2b22d24e36858 Mon Sep 17 00:00:00 2001 From: Kiran Niranjan Date: Sat, 27 Apr 2024 15:32:24 +0530 Subject: [PATCH] SDA-4501 (Initialize new data if the user config is unable to parse) (#2136) * SDA-4501 - Initialize new user config if data is corrupted * SDA-4501 - Delete file before initializing --- src/app/config-handler.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/app/config-handler.ts b/src/app/config-handler.ts index e91af4b2..0fe9fbb1 100644 --- a/src/app/config-handler.ts +++ b/src/app/config-handler.ts @@ -635,7 +635,17 @@ class Config { fs.unlinkSync(this.userConfigPath); return; } - this.userConfig = this.parseConfigData(userConfig); + try { + this.userConfig = this.parseConfigData(userConfig); + } catch (e) { + logger.info( + `config-handler: User config file is corrupted. Initializing new file`, + e, + ); + fs.unlinkSync(this.userConfigPath); + this.userConfig = {}; + await this.initializeUserConfig(); + } } logger.info(`config-handler: User configuration: `, this.userConfig); }