Repository navigation
Description
Found while checking AniList's 25/10/2026 site update (changelog) against our code. The path has always existed; the update is what makes it routine:
Resetting or changing your password will now log you out from all your devices and apps for increased security [...] This might cause you to be logged out with this update if your device sessions were in an unusual state.
Server-side token revocation used to be rare enough to ignore. It is now one ordinary account action away, and it is the one failure our error UI cannot recover from.
Problem
A revoked token reads as valid locally, so the app never signs out — and the state it lands in has no sign-in control anywhere on screen.
1. Nothing notices the token is dead
TokenStore.GetAsync decides state purely from the locally stored expiry:
if (expiresAt is not null && expiresAt <= _timeProvider.GetUtcNow())
{
return new TokenLookup(TokenState.Expired, null, expiresAt);
}
return new TokenLookup(TokenState.Valid, accessToken, expiresAt);AniList tokens are long-lived — #79's captured log shows expiresAt=04/24/2027 — so a token revoked today keeps reporting Valid for about a year. AuthService.GetAccessTokenAsync hangs the only automatic sign-out off the state that can no longer be reached:
if (lookup.State is TokenState.Expired)
{
_logger.LogInformation("AUTH token-check: expired (expiresAt={ExpiresAt}), signing out.", lookup.ExpiresAt);
// ... await SignOutAsync();
return null;
}Nothing anywhere clears a token that the server has rejected. SignOutAsync has exactly three callers: AuthService on local expiry, and the two Settings/Library Sign Out buttons.
2. "Authenticated" is computed from that same stale check
SettingsPageModel.cs:1190:
private async Task RefreshAuthStateAsync()
{
var token = await _authService.GetAccessTokenAsync().ConfigureAwait(true);
IsAuthenticated = !string.IsNullOrWhiteSpace(token);
}So with a revoked token, IsAuthenticated is true. Every request then fails with AniList's HTTP 400 + "Invalid token", which AniListErrorClassifier correctly maps to ApiErrorKind.Authentication — and which IsTransient then burns a pointless retry and 750 ms on first, by design (#79, correct for the genuinely transient case it was built for).
3. The state it lands in has no way out
SettingsPageModel.cs:325-348 picks the branch on cold start — no _loadedUser, but IsAuthenticated true:
else if (IsAuthenticated)
{
// Full-page error state — no cached data to fall back on.
ErrorTitle = apiEx?.UserTitle ?? "Something Went Wrong";
ErrorSubtitle = apiEx?.UserSubtitle ?? "An unexpected error occurred. Try again or check back later.";
ErrorIconGlyph = apiEx?.IconGlyph ?? Glyphs.Regular.ErrorCircle24;
CurrentState = PageState.Error;
}
else
{
// Auth check itself failed; fall back to Unauthenticated so the user
// can retry sign-in from the login card.
await _feedback.ShowSnackbarAsync(apiEx?.UserTitle ?? "Failed to load profile.");
CurrentState = PageState.Unauthenticated;
}That last branch is the behaviour we want, and its comment says so. It is unreachable here precisely because the dead token reads as authenticated. MediaListPageModel.cs:407-416 is worse — its else has no IsAuthenticated guard at all, so with no cached sections it always goes to full-page Error.
The card the user then gets says the right thing and offers nothing that can act on it. AniListApiException:
ApiErrorKind.Authentication => "Session Expired",
ApiErrorKind.Authentication => "Please sign in again to continue.",ErrorStateView.xaml contains exactly four controls: Try Again (RetryCommand), Copy and Share (both gated behind HasErrorDetails), and Report a problem. There is no sign-in or sign-out affordance. AuthActionsView — the only thing in the app holding a Sign In / Sign Out button — appears in four places, none of them reachable from PageState.Error:
| Location | State it lives in |
|---|---|
SettingsPage.xaml:55 |
StateKey="Unauthenticated" |
AnimeLibraryPage.xaml:86 |
StateKey="Unauthenticated" |
MangaLibraryPage.xaml:86 |
StateKey="Unauthenticated" |
SettingsLoadedContentView.xaml:494 |
Content (attached only when IsAuthenticated and loaded) |
The Error state's own XAML comment confirms it replaces page content outright — "Error: full-page error view (no cached data fallback)".
So the user reads "Session Expired — Please sign in again to continue" with Try Again as the only button, and Try Again re-runs the same request with the same dead token forever. The remaining ways out are clearing the app's data, reinstalling, or waiting up to a year for the stored expiry to pass.
Impact
Change your AniList password, reopen the app, and every tab that needs the API is bricked with no in-app recovery. This is a routine account action now, and the update warns it may fire for some users on its own.
Worth noting what masks it: if Settings or Library already loaded successfully this session, the _loadedUser is not null / hadExistingSections branch runs first and gives a snackbar over stale content — and from there the Sign Out button in SettingsLoadedContentView is reachable. The dead end is specifically the cold start, which is exactly the state after reopening the app following a password change.
This was deferred once, on an assumption that no longer holds
#79 (closed) added the once-only retry for transient "Invalid token" responses and explicitly scoped this out:
Out of scope — N-consecutive-failure tracking that triggers full re-authentication. If the retry-once path still fails repeatedly across operations, that's a real revocation and the caller will eventually push the user to re-auth via the existing error UI.
and described the error state as one "which on Settings/MyAnime lets the user retry or sign in again". That was the reasonable reading at the time, but the error card has no sign-in control — so the escape hatch the deferral depended on was never there. The deferral was sound; the assumption underneath it was wrong.
Constraint
- Do not sign out on a single
Authenticationfailure. AniListClient: auto-retry once on transient Invalid token 400 responses #79 documents AniList returning400 "Invalid token"for one in-flight request and accepting the identical bearer token ~150 ms later, repeatedly, in one session. Signing out on the first failure would log users out during AniList's ordinary instability — which is the bug AniListClient: auto-retry once on transient Invalid token 400 responses #79 was fixing. Whatever distinguishes "revoked" from "blipping" has to survive that trace. - Signed-out browsing must keep working. Much of the app is usable unauthenticated (Unauthenticated AniList requests are 403'd, so signed-out users get a dead app and a false "AniList is Down" banner #160), so landing in the signed-out state has to leave Discover/Search/details intact rather than dead.
- Sign-out touches SecureStorage and the Android
CookieManageron the main thread and can throw;AuthService.cs:46-65wraps it for exactly that reason, and anything calling it from a background or error path inherits that care. DiagnosticsLogBufferandprevious-session.logare deliberately not cleared on sign-out (AGENTS.md:159) — an automatic sign-out must not become a backdoor that wipes diagnostics mid-incident.
Options
Not settled — recorded while the context was fresh; design at kickoff against the real code.
A. Put a sign-in action on the error card. Give ErrorStateView an optional secondary action and have the Authentication kind populate it with sign-out-then-sign-in. Smallest change, makes the subtitle's instruction actionable, and fixes the dead end without having to tell revocation from a blip at all — the user decides by pressing it. Leaves the stale token sitting in storage until they do.
B. Count consecutive Authentication failures, then sign out. The shape #79 described. Needs a threshold and a scope (per operation? across operations? reset on any success?), and a wrong threshold either logs people out during AniList instability or leaves the dead end intact for longer. Fixes the state rather than just the exit from it.
C. Validate on resume. On app resume, or on the next Viewer call after a cold start, treat an Authentication failure from that one known-good probe as authoritative and sign out. Narrower than B — one designated request rather than a counter over all of them — and a cold start is exactly when this bites.
Leaning A first, then C. A is small, independently useful for any future auth failure, and does not require guessing a threshold; C then clears the dead token so the app stops retrying against it. B's counter is the part most likely to misfire against the #79 trace. Also worth checking during kickoff whether IsTransient should keep retrying Authentication once the error is known-persistent — currently every request in the bricked state pays the extra 750 ms.
Related
- AniListClient: auto-retry once on transient Invalid token 400 responses #79 — added the transient
"Invalid token"retry and deferred this work; its stated assumption about the error UI is what this issue disproves. - NotFound is a dead end: no Sentry event, no shareable details, no retry, and any "Not Found" substring triggers it #158 —
NotFoundwas a dead end in the same shape (an error card with nothing useful to press) and was fixed in4c682a3; theAuthenticationcard still is one, and has no escape at all. - Unauthenticated AniList requests are 403'd, so signed-out users get a dead app and a false "AniList is Down" banner #160 — signed-out browsing, which the recovery path must not break.
- Offline mode: read-only list access when no connection #75 — offline mode; shares the question of what the app does with a usable cache and an unusable API.
Activity