fix(auth): improve network error messages and add retry resilience during token polling#579
Draft
fix(auth): improve network error messages and add retry resilience during token polling#579
Conversation
…ring token polling - http_client.py: fall back to exception class name when str(httpx.RequestError) is empty, preventing the confusing trailing 'Network error: ' with no detail - device_flow.py: retry transient network errors up to max_network_errors (3) consecutive times before failing, so a brief connectivity blip no longer kills the entire login flow - tests: add test for empty-message fallback; update network-error test to assert 3 retries are made; add new transient-recovery test Co-authored-by: openhands <openhands@all-hands.dev>
Contributor
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
Two bugs fixed in the OAuth 2.0 device flow login path, surfaced by a real login failure:
Bug 1 — Confusing empty error message (
http_client.py)httpx.RequestErrorsubclasses (e.g.ConnectError) can produce an emptystr(e). The previous code did:Fix: fall back to the exception class name when the string is empty:
Bug 2 — Single network blip kills the entire login (
device_flow.py)The polling loop raised immediately on the first
AuthHttpError, even though the error could be transient (brief connectivity hiccup, DNS blip, etc.). A 10-minute polling window that fails on the very first attempt is not resilient.Fix: track consecutive network errors and only raise after
max_network_errors(default: 3) consecutive failures. Each failed attempt sleeps forintervalseconds before retrying, consistent with the rest of the polling loop.Commands run
Before / After
Before:
After (persistent failure):
After (transient failure — now recovers silently):
🚀 Try this PR