Repository navigation
fix: detect network errors from Authenticate as 503, not generic 500 - #68
Merged
Merged
Conversation
Found live 2026-07-16 testing with real admin credentials against a genuinely stopped Jellyfin container (not just slow/unreachable-but- listening): Authenticate() returned a real, non-nil *url.Error (DNS lookup failure for the Jellyfin hostname, since the container isn't on the Docker network when stopped) -- a completely different code path from #67's fix, which only handles the case where the library's internal panic-recovery returns a nil error with a zero-value user. Neither ErrUnauthorized nor ErrForbidden match a network error, so this fell through to a generic 500 "Jellyfin error", which is what was observed testing login with real credentials right after #67 deployed. Detects the network-failure shape (*url.Error, what net/http.Client.Do always wraps transport-level failures in) and returns 503 "Jellyfin unreachable" instead, matching the message #67 already produces for the other failure mode.
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 testing with real credentials right after #67 deployed: login still returned a plain
500 "Jellyfin error", not the503#67 was supposed to produce.Root cause: #67 only handles the case where
hrfee/mediabrowser's internal panic recovery (Authenticate()'s owndefer mb.timeoutHandler()) swallows a panic and returns a nil error with a zero-value user. But when Jellyfin's container is genuinely stopped (not just erroring or slow), the DNS lookup for the Jellyfin hostname fails outright —mb.httpClient.Do(req)fails at the transport level andAuthenticate()returns a real, non-nil*url.Errorlong before it ever reaches the panic-prone line. That's a completely different, ordinary error path, not the recovered-panic case at all.Neither
ErrUnauthorizednorErrForbiddenmatch a network error, so it fell through to the generic500 "Jellyfin error"branch.Change
Detects the network-failure shape (
*url.Error, whichnet/http.Client.Doalways wraps transport-level failures in — DNS, connection refused, TLS errors) and returns503 "Jellyfin unreachable"instead, matching the message #67 already produces for its case.Context
This is the third attempt at getting the login-path error message right tonight (#62, then #67, now this). Each one was a real, distinct code path — #62's panic recovery genuinely can happen if Jellyfin responds with something unexpected while reachable; #67's nil-error case is real if that panic recovery swallows things silently; this PR's network-error case is what actually happens when the container is stopped, which is the scenario that's been live on batcave all night. Full incident writeup with the complete ladder is in project memory for anyone picking this up next.
Test plan