fix(seerr): add main.mediaServerType to settings.json to prevent crash

Seerr's checkOverseerrMerge calls Settings.load with raw=true, which
replaces this.data entirely with file contents. If settings.main is
absent (as in our jellyfin-only restore), it crashes at line 418:
'Cannot read properties of undefined (reading apiKey)'.

restore.js now ensures settings.main exists and mediaServerType=JELLYFIN,
which both prevents the crash and causes checkOverseerrMerge to return
early (migration already done).
This commit is contained in:
Will Anderson
2026-04-11 01:44:41 -05:00
parent 71f335c153
commit 4031628f4b
+13 -1
View File
@@ -29,14 +29,26 @@ data:
if (fs.existsSync(SETTINGS)) {
try { settings = JSON.parse(fs.readFileSync(SETTINGS, 'utf8')); } catch(e) {}
}
// Seerr's Settings.load runs in raw mode during the overseerrMerge check,
// which replaces this.data entirely with the file contents. If settings.main
// is absent, it crashes at "this.data.main.apiKey" (settings/index.js:418).
// Ensure main exists with mediaServerType=JELLYFIN so the merge check is skipped.
if (!settings.main) {
settings.main = {};
}
if (!settings.main.mediaServerType) {
settings.main.mediaServerType = 'JELLYFIN';
console.log('Set main.mediaServerType = JELLYFIN');
}
if (!settings.jellyfin || !settings.jellyfin.apiKey) {
console.log('Jellyfin apiKey missing — restoring from defaults');
settings.jellyfin = JSON.parse(fs.readFileSync(DEFAULTS, 'utf8'));
fs.writeFileSync(SETTINGS, JSON.stringify(settings, null, 2));
console.log('Restored Jellyfin config');
} else {
console.log('Jellyfin config present, skipping restore');
}
fs.writeFileSync(SETTINGS, JSON.stringify(settings, null, 2));
console.log('Settings written successfully');
---
apiVersion: apps/v1
kind: Deployment