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
This commit is contained in:
Kiran Niranjan 2024-04-27 15:32:24 +05:30 committed by GitHub
parent 8c066b963f
commit 020cd05eab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -635,7 +635,17 @@ class Config {
fs.unlinkSync(this.userConfigPath); fs.unlinkSync(this.userConfigPath);
return; 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); logger.info(`config-handler: User configuration: `, this.userConfig);
} }