Repository navigation
fix: discover a shared dex host from the login redirect; clearer error when a search backend is unavailable - #80
Merged
Conversation
…arch backend clearly Login (and token refresh) failed with "failed to parse device code response: invalid character '<'" on installs whose dex is served from an auth host shared with another install, i.e. neither <server>/dex nor auth.<server>/dex. When neither candidate answers OIDC discovery, read where the server's web login (GET /login, not followed) redirects for /dex/auth and use that host, provided it serves its own discovery document. A search backend that is down made the web server answer 502/503/504 with an HTML page, surfaced as a bare "HTTP 502: Bad Gateway". Such unstructured gateway errors now become search_unavailable with a readable message, which the e2e suite already treats as a backend gap (skip) rather than a CLI failure. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… enabled A 502/503/504 from the web server can mean the search backend is down, or that the install does not run it at all. Drop "try again later". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
krynju
marked this pull request as draft
November 3, 2026 10:46
- Discovery probes follow redirects again; only the /login read is no-follow, on a copy of the client. - Read /login alongside the probes instead of after both fail, and do not re-probe a redirect to a candidate that just failed. - Fold the test-only pickAuthServer wrapper into probeAuthServer. - A gateway 504 is reported as search_timeout with a hint to narrow the query, not as an unavailable backend. - Update the searchError and CLAUDE.md docs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, comments) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
krynju
marked this pull request as ready for review
November 3, 2026 10:52
pankgeorg
approved these changes
Nov 3, 2026
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
Login on installs with a shared auth host
jh auth login(and token refresh) assumed the dex OIDC endpoints live at either<server>/dexorauth.<server>/dex. Some installs authenticate through a dex hosted on a different, shared auth domain. On those, both probes fail and login falls back to<server>/dex. That path returns an HTML error page, and login fails with:The fix: when neither candidate answers OIDC discovery,
discoverAuthServernow checks where the server's own web login redirects. It sendsGET https://<server>/loginwithout following the redirect, and if theLocationis an https/dex/authURL, it uses that host. The host is accepted only if it serves its own discovery document (issuerhttps://<host>/dex), the same check the existing candidates go through. The server already decides where its own users log in, so this trusts nothing new. Installs that were already discovered pick the same host as before. The/loginread runs alongside the existing probes, so the shared-host case pays no extra round trip, and its result is used only when both probes fail. It never follows the redirect; the existing discovery probes keep following redirects as before.Refresh and
jh run setup(therefresh_urlwritten toauth.toml) go through the sameauthServerFor, so they pick up the discovered host too.Search when the backend is unavailable
When a search backend can't be reached (it is down, or the install doesn't run it), the web server answers 502/503 with an HTML page.
jh searchused to print onlyHTTP 502: Bad Gateway. Unstructured 502/503 errors now becomesearch_unavailablewith a readable message:An unstructured 504 (the backend took longer than the gateway waits, usually an expensive query) becomes
search_timeout, with a hint to narrow the pattern or filter by--package/--registry. A structured{code, message}body from the search API is still reported unchanged. The e2e suite already treatssearch_unavailableas a backend gap, so these runs now skip instead of failing.Tests
dexAuthHost(status, scheme, path and relative-URL cases),loginRedirectAuthServeragainst anhttptestTLS server (including that it never follows the redirect, whatever the client's policy),probeAuthServer, and gateway handling indecodeSearchErrorgo vet ./...,go vet -tags e2e ./e2e/...,go test ./...passauth status,auth refresh,run setup, and the full live e2e suite (go test -tags e2e ./e2e/...): all pass. The only skips are endpoints that are unavailable or need admin rights on that instance.🤖 Generated with Claude Code