[bug] Avoid modifying cached config; Fix bug 77490

This commit is contained in:
Sergey Konovalov
2025-10-11 11:31:06 +03:00
parent 198993ab60
commit 5b5851e603

View File

@ -341,6 +341,12 @@ async function getPluginSettings(ctx) {
async function getPluginSettingsForInterface(ctx) { async function getPluginSettingsForInterface(ctx) {
let pluginSettings = await getPluginSettings(ctx); let pluginSettings = await getPluginSettings(ctx);
// Create deep copy to avoid modifying cached config
if (pluginSettings) {
pluginSettings = JSON.parse(JSON.stringify(pluginSettings));
}
//check empty settings //check empty settings
if (pluginSettings && pluginSettings.actions) { if (pluginSettings && pluginSettings.actions) {
let isEmptySettings = true; let isEmptySettings = true;
@ -353,11 +359,11 @@ async function getPluginSettingsForInterface(ctx) {
pluginSettings = undefined; pluginSettings = undefined;
} }
} }
//remove keys from providers - create deep copy to avoid modifying cached config
//remove keys from providers
if (pluginSettings?.providers) { if (pluginSettings?.providers) {
for (const key in pluginSettings.providers) { for (const key in pluginSettings.providers) {
if (pluginSettings.providers[key]?.key) { if (pluginSettings.providers[key]?.key) {
pluginSettings.providers[key] = JSON.parse(JSON.stringify(pluginSettings.providers[key]));
pluginSettings.providers[key].key = ''; pluginSettings.providers[key].key = '';
} }
} }