Repository navigation
Conversation
Both sign-in poll loops (the browser cli_code redeem and the device flow) now treat an HTTP 5xx answer, or code internal_error, like a dropped connection: it counts against maxConsecutivePollFailures, the loop sleeps its poll interval (stretched to Retry-After when that is longer, never past the grant deadline) and polls again. Four in a row still give up with "giving up after 4 consecutive poll failures". The platform now answers a database blip on the grant read with 503 internal_error (sourceplane/orun-cloud#2356), but the released CLI ended the login on the first 503, so a blip during the browser flow still cost the user their sign-in. 401, 403, 404 and 410 stay terminal whatever their code; Refresh is unchanged (it already keeps the session on a 503). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Rahul Varghese <rahul.varghese@sourceplane.ai>
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.
What changed
orun auth login(browser flow) andorun auth login --devicekeep waiting for approval when the platform answers a poll with an HTTP 5xx, or with codeinternal_error, instead of ending the login on the first one. Such an answer is handled like a dropped connection: it counts againstmaxConsecutivePollFailures, the loop sleeps its poll interval (or the server'sRetry-Afterwhen that is longer, never past the grant deadline) and polls again. Four in a row still give up withgiving up after 4 consecutive poll failures, and the error wraps the server's answer.retryablePollError: any 5xx or codeinternal_erroris retryable. 401, 403, 404 and 410 stay terminal whatever their code.pollRetryWait: the poll interval, stretched toRetry-After, capped at the time left on the grant.BrowserLogin(cli_code redeem) andDeviceLoginroute 5xx into the existing transport-failure branch. The counter is renamedpollFailsbecause it no longer counts only transport failures. The 429 branches andRefreshare unchanged.Why
During the 2026-11-11 prod database outage, sign-in was impossible. sourceplane/orun-cloud#2356 fixed the platform side: identity-worker now answers a database blip on the grant read with a retryable 503
internal_errorinstead of 401not_found, and a device poll whose grant read failed answers RFC 8628slow_down. The released CLI already handles that. But the CLI still returned on any non-pending, non-429*APIErrorin the cli_code loop, and on anything but 403/410/429 in the device loop. So a single blip during the browser flow still ended the login, now with a clear "temporarily unavailable" error rather than a misleading one. This closes that gap.Refreshis left alone: the platform answers a store failure there with 503, andRefreshSessionalready keeps the stored session in that case (only 401/404/410 clear it).How it was verified
go test ./internal/cliauth/...passes (ok … 46s),go vet ./internal/cliauth/andgofmt -lare clean.New cases in
internal/cliauth/login_test.go. The fake backend gainsbrowserUnavailable/deviceUnavailable(polls answered 503internal_error, placed after the pending polls, so the blip lands on the poll that would redeem the approved grant) andunavailableRetryAfter:TestBrowserLogin_UnavailableMidPollRetried: pending → 503 → redeem completes the login (3 polls).TestBrowserLogin_UnavailableOutageTerminal: 503 on every poll gives up after exactly 4 polls with the consecutive-poll-failures error wrapping the 503*APIError.TestDeviceLogin_UnavailableMidPollRetried: pending → 503 withRetry-After: 2→ complete. The test asserts ≥ 3 s elapsed, so the 2 sRetry-Afterwas honored over the grant's 1 s interval.TestDeviceLogin_UnavailableOutageTerminal: the same give-up as the browser case, on the device flow.TestRetryablePollError,TestPollRetryWait: table tests for the classifier (including 401internal_error→ terminal, 429 → not this branch) and the wait.With
retryablePollErrorforced tofalse(the old behavior), all four flow tests fail withredeem Orun login: Service temporarily unavailable (internal_error)/DeviceLogin error = Service temporarily unavailable (internal_error).Checklist
make fmt lint testpasses locally (forinternal/cliauth: gofmt, go vet, go test)git commit -s)🤖 Generated with Claude Code