-
Notifications
You must be signed in to change notification settings - Fork 33
Add Device Authorization Grant (RFC 8628) for headless/container environments #916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mickume
wants to merge
5
commits into
jumpstarter-dev:main
Choose a base branch
from
mickume:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
f094dfb
fix(#16, nightshift): add Device Authorization Grant (RFC 8628) for h…
mickume e68c961
Merge branch 'jumpstarter-dev:main' into main
mickume 15f4b80
fix(cli-common): suppress ty false positive on nonlocal poll_count (f…
mickume 09be0b8
fix(#17, nightshift): update shell_test to match retry-after-reauth b…
mickume ca04c1a
Merge branch 'jumpstarter-dev:main' into main
mickume File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
_ReauthSucceededcan leak out uncaught when the retry hits aBaseExceptionGroup._try_reauth_or_handle'sallow_reauth=Falsebranch callshandler(exc, login_func)without catching_ReauthSucceeded(Line 272-273). For the single-exception path this is safe only because_call_with_exception_handlingshort-circuitsConnectionErrorbefore allow_reauth=False ever reaches the handler (Line 291-292:if isinstance(e, ConnectionError) and not allow_reauth: raise ClickExceptionRed(...)). No equivalent guard exists for theBaseExceptionGroupbranch (Line 287-289): if the retry (allow_reauth=False) raises aBaseExceptionGroupwhose leaf is an "expired"ConnectionError,_handle_exception_group_with_reauth→_handle_connection_error_with_reauth(Line 218-233) still callslogin_funcagain and raises_ReauthSucceeded(), which now propagates uncaught out ofwrapped()as a raw internal exception instead of aclick.ClickException. This also breaks the "retries the original call exactly once... surfaced normally" guarantee documented on Line 308-310, since a leaked_ReauthSucceededis not a normal, user-facing error.The cleanest fix is to always catch
_ReauthSucceededin_try_reauth_or_handleand convert it to a proper error when re-auth isn't allowed, rather than duplicating theConnectionError-specific short-circuit for every call site.🐛 Proposed fix
def _try_reauth_or_handle(handler, exc, login_func, *, allow_reauth: bool) -> bool: """Attempt re-auth via *handler*; return True if re-auth succeeded. - When *allow_reauth* is False the handler is called without catching - ``_ReauthSucceeded`` — any re-auth signal propagates as a normal error. + When *allow_reauth* is False, a ``_ReauthSucceeded`` signal raised by the + handler is converted into a ``ClickExceptionRed`` instead of retrying + again, guaranteeing at most one re-auth attempt regardless of whether the + triggering exception arrived standalone or inside a ``BaseExceptionGroup``. """ - if allow_reauth: - try: - handler(exc, login_func) - except _ReauthSucceeded: - return True - else: - handler(exc, login_func) - return False + try: + handler(exc, login_func) + except _ReauthSucceeded: + if allow_reauth: + return True + raise ClickExceptionRed(str(exc)) from None + return FalseConsider adding a test that raises a
BaseExceptionGroupwrapping an expired-tokenConnectionErroron the retried call, to lock in this fix. As per coding guidelines, "Provide comprehensive package test coverage, prioritizing end-to-end tests that start a server and client; use mocks when system tools, services, or platform compatibility make end-to-end testing impractical."📝 Committable suggestion
🤖 Prompt for AI Agents
Source: Coding guidelines