From cc418e587459a95809af164aeefe9882f078f4ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20F=C3=B6rtsch?= Date: Mon, 13 Apr 2026 12:33:26 +0200 Subject: [PATCH] fix: jellyfin save now matches the new { ok, saved, testError } response shape MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When I switched the settings UI to read result.saved to decide whether the '✓ Saved & connected' / '⚠ Saved, but connection test failed' / '✗ error' states should appear, I only updated the Radarr and Sonarr endpoints to return that shape. Jellyfin still returned bare { ok: true } so the UI saw saved=undefined and showed '✗ Save failed' even on a perfectly successful save — making it look like Jellyfin had stopped working. Bring Jellyfin in line: - Save the URL+API key (and setup_complete) BEFORE running testConnection so the input survives a failed probe (same fix as Radarr/Sonarr). - Only do the admin-user discovery on test success. - Return { ok, saved, testError }. --- server/api/settings.ts | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/server/api/settings.ts b/server/api/settings.ts index 0838e8b..4e328ba 100644 --- a/server/api/settings.ts +++ b/server/api/settings.ts @@ -19,22 +19,27 @@ app.post("/jellyfin", async (c) => { if (!url || !apiKey) return c.json({ ok: false, error: "URL and API key are required" }, 400); - const result = await testJellyfin({ url, apiKey }); - if (!result.ok) return c.json({ ok: false, error: result.error }); - + // Save first so the user's input is never silently dropped on a test + // failure (matches the Radarr/Sonarr pattern). The frontend reads the + // { ok, saved, testError } shape to decide what message to show. setConfig("jellyfin_url", url); setConfig("jellyfin_api_key", apiKey); setConfig("setup_complete", "1"); - try { - const users = await getUsers({ url, apiKey }); - const admin = users.find((u) => u.Name === "admin") ?? users[0]; - if (admin?.Id) setConfig("jellyfin_user_id", admin.Id); - } catch { - /* ignore */ + const result = await testJellyfin({ url, apiKey }); + + // Best-effort admin discovery only when the connection works; ignore failures. + if (result.ok) { + try { + const users = await getUsers({ url, apiKey }); + const admin = users.find((u) => u.Name === "admin") ?? users[0]; + if (admin?.Id) setConfig("jellyfin_user_id", admin.Id); + } catch { + /* ignore */ + } } - return c.json({ ok: true }); + return c.json({ ok: result.ok, saved: true, testError: result.ok ? undefined : result.error }); }); // Persist values BEFORE testing the connection. The previous behaviour