Repository navigation
fix: fall back to stale user cache instead of erroring when sync fails - #71
Merged
jay739 merged 1 commit intoJul 16, 2026
Merged
Conversation
Found live 2026-07-16: with Jellyfin down, GetUsers/SearchUsers (the admin panel's user list, needed to pick recipients for a maintenance announcement) returned a plain 500 "Couldn't get users" instead of the last successfully-cached list. MaybeSync's own doc comment already states the intended behavior for a failed sync: "expecting you to use the old cache data." That's true for a background sync (the common case, WaitForSyncTimeout not yet elapsed), but GetUserDTOs discarded c.Ref on ANY MaybeSync error, including the blocking-sync case (Jellyfin unreachable long enough that WaitForSyncTimeout elapses too) -- exactly contradicting the cache's own stated purpose. Falls back to c.Ref when it has data, logging the sync failure instead of hiding it. Doesn't help retroactively (this session's cache was empty going into tonight's incident, since the container had been restarted several times while Jellyfin was already down), but fixes the gap for any future outage where the cache had a chance to populate first.
3 tasks
jay739
added a commit
that referenced
this pull request
Jul 16, 2026
Found live 2026-07-16, the second time in one night: the admin panel's Users tab is completely unusable during a Jellyfin outage, even after fixing the underlying panics/500s (#62-#71) -- GetUsers/SearchUsers fundamentally need a live Jellyfin connection to list users, since Jellyfin IS the user database. There's no way to make that endpoint work without Jellyfin reachable. What CAN work: app.storage's own persistent badger DB already stores an EmailAddress record (Jellyfin ID, email, label, contact/admin flags) per user, independent of Jellyfin's own availability. This was previously only accessible via internal code paths (housekeeping cleanup, migrations) with no API route exposing it -- recovering it during tonight's incident required a one-off standalone Go program reading the badger DB file directly. Adds GET /users/persisted, returning every stored EmailAddress record. Trades completeness (no online status, no Jellyfin username, no last-active -- just enough to know who to email) for actually working when Jellyfin is down. Same auth group (webAuth) as every other /users route.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Found live tonight while trying to get a user list to send maintenance/downtime emails with Jellyfin down:
GetUsers/SearchUsersreturned a plain500 "Couldn't get users"instead of the last successfully-cached list.MaybeSync's own doc comment already states the intended design: "expecting you to use the old cache data" on a failed sync. That's honored correctly for a background sync (the common case), butGetUserDTOsdiscardedc.Refon anyMaybeSyncerror, including the blocking-sync case (Jellyfin unreachable long enough thatWaitForSyncTimeoutelapses too) — directly contradicting the cache's own stated purpose.Change
GetUserDTOsnow falls back toc.Refwhen it has data and the sync failed, logging the failure instead of hiding it (viaapp.err.Printf), instead of returningnil, errunconditionally.Limitation (documented, not fixed here)
This doesn't help retroactively for tonight's specific incident — the
omnifincontainer was recreated several times while Jellyfin was already down, so the in-memory cache was empty (never populated), not stale. For tonight's actual mailing list, the persistedEmailAddressrecords were recovered directly from the on-disk badger DB (app.storage.GetEmails(), independent ofUserCache) via a one-off read-only tool against a copy of the DB file — that data survives container restarts since it's real persistent storage, not an in-memory cache. This fix protects against the next time Jellyfin goes down after omnifin's been running long enough to populate the cache first.Test plan
GetUsers/SearchUsersreturn the stale list instead of a 500