The web handler routed its two keep-the-session paths through the mobile one,
which had since grown a leading force-logout branch. That branch could not fire
on web — it re-tests the same classifier call the web handler had already
evaluated to false — but the safety rested on a call-ordering invariant inside
the web handler rather than on anything structural. Adding an earlier delegation
would have quietly made it live and started logging web users out on failures
already ruled transient.
Extract the tail both handlers shared into _propagateKeepingSession and have web
call it directly, so the logout branch leaves web's call graph entirely.
Cover the behaviour too: an OAuthAuthorizationError — the mobile error shape —
arriving on web must keep the session. Verified by mutation: re-coupling both
delegation sites and pointing the guard at the mobile classifier fails exactly
these two tests.
Pure move, no behaviour change. Also splits a doc comment that had been merged
into the paragraph above it.
A confirmed mobile rejection was rethrown out of the refresh helper, caught by
the outer handler in onError(), logged there as a generic event, and only then
routed to the platform handler that logged the real structured one. One failure,
two events, the less useful of them arriving first.
Route a rejection the platform handler already classifies straight to it, so the
outer catch never sees it.
Failures that stay unclassified are still rethrown on purpose: the generic event
is then their only trace, and dropping it would make them invisible. Both halves
are covered — one event for a rejection, the generic event retained for the rest.
On mobile the refresh runs through flutter_appauth (native), so a rejected
refresh token never reaches Dio and the statusCode == 400 branch is unreachable.
The rejection arrives as an OAuthAuthorizationError carrying the RFC 6749 code
from the response body, and nothing handled it: the dead session was kept, and
because the refresh-attempt marker lives on the request, every new request
retried the same doomed refresh. The mailbox spun forever instead of sending
the user back to login.
Force the logout when — and only when — the classifier confirms a bad-grant
code. Transient codes (server_error, temporarily_unavailable) and failures that
never reached the OAuth server keep the session, so a flaky mobile connection
still does not sign the user out.
Also pin the native-error to domain-error boundary the fix depends on. Every
test so far constructed OAuthAuthorizationError directly, leaving both the
conversion in handleException and the wiring that reaches it unproven — a
plugin upgrade that stopped populating platformErrorDetails.error would have
resurrected the bug with the suite still green. The client test is verified by
mutation: dropping the catch that calls handleException fails it.
The mobile invalid_grant case in the stale-401 group changes verdict here: it
asserted the session survived, which was the bug.