editing a secret provider no longer wipes its stored token

This commit is contained in:
jarek committed 2026-08-20 08:28:26 +02:00
1 parent b56e1ef7f9
commit 8b67fc0662
1 file changed
+11 -11
+11 -11
View File
@@ -379,18 +379,18 @@ export async function updateSecretProvider(
if (data.config !== undefined) { if (data.config !== undefined) {
// The edit form pre-fills non-secret fields but leaves the token blank to mean // The edit form pre-fills non-secret fields but leaves the token blank to mean
// "keep the stored secret". Merge the incoming config OVER the existing one so a // "keep the stored secret". Merge the incoming config OVER the existing one so a
// blank/absent secret keeps its stored value instead of being wiped. Only applies // blank/absent secret keeps its stored value instead of being wiped. The edit
// when the provider type is unchanged (a type change is a full re-config). // form always sends `type` (its dropdown is read-only), so gate on the type not
// CHANGING rather than on it being absent - a genuine type change is a full
// re-config and skips the merge. (#1432)
let merged: Record<string, unknown> = { ...(data.config as Record<string, unknown>) }; let merged: Record<string, unknown> = { ...(data.config as Record<string, unknown>) };
const typeUnchanged = data.type === undefined; const existing = await getSecretProviderById(id);
if (typeUnchanged) { const typeUnchanged = data.type === undefined || (existing !== undefined && data.type === existing.type);
const existing = await getSecretProviderById(id); if (typeUnchanged && existing) {
if (existing) { merged = mergeProviderConfigForWrite(
merged = mergeProviderConfigForWrite( data.config as Record<string, unknown>,
data.config as Record<string, unknown>, existing.config as Record<string, unknown>
existing.config as Record<string, unknown> );
);
}
} }
const encrypted = encrypt(JSON.stringify(merged)); const encrypted = encrypt(JSON.stringify(merged));
if (encrypted) updateData.config = encrypted; if (encrypted) updateData.config = encrypted;