fix(settings): accept omitted optional values after upgrades

Restore the v2.0.35 renderer settings validation behavior that was lost when the download path returned to the v2.0.28 baseline. Ignore undefined optional values at top level and inside structured settings while continuing to reject unknown concrete keys and invalid types. Cover a full settings save containing a Real-Debrid account status without the optional email field, plus obsolete optional-field handling.
This commit is contained in:
Sucukdeluxe
2026-08-15 00:18:01 +02:00
parent 31e87b80f3
commit 5980b48d60
2 changed files with 48 additions and 1 deletions
+8 -1
View File
@@ -30,7 +30,11 @@ function validateJsonValue(value: unknown, depth = 0): void {
}
const entries = Object.entries(value as Record<string, unknown>);
if (entries.length > 10_000) invalid();
entries.forEach(([, entry]) => validateJsonValue(entry, depth + 1));
entries.forEach(([, entry]) => {
if (entry !== undefined) {
validateJsonValue(entry, depth + 1);
}
});
}
function validateTopLevelType(value: unknown, expected: unknown): void {
@@ -64,6 +68,9 @@ export function validateRendererSettingsUpdate(value: unknown, current: AppSetti
const input = value as Record<string, unknown>;
const output: Record<string, unknown> = {};
for (const [key, entry] of Object.entries(input)) {
if (entry === undefined) {
continue;
}
if (DERIVED_KEYS.has(key)) {
continue;
}