🩹 fix(auth): distinguish 'stored but unreadable' credentials from 'none' (#746)#747
Merged
Merged
Conversation
…ne" (#746) `yt auth status` reported "No authentication credentials found" when the config recorded a keyring-backed login (`YOUTRACK_API_KEY=[Stored in keyring]` + base URL) but the token could no longer be read from the OS keyring — e.g. after an upgrade/move relocated the CLI binary and the OS keychain stopped granting the new binary access. That misleads users into thinking they were never logged in. Add `AuthManager.credentials_stored_but_unreadable()` and use it in `auth status` to show an actionable message ("stored but can't be read … run `yt auth login` to re-store") instead of the generic no-credentials error. Not a regression from 0.24.5: the credential store/read path (security.py, config.py, models.py) is byte-identical to 0.24.4 and no dependency changed; verified by an in-process keyring round-trip. This is a diagnostics improvement for the underlying OS-keychain behavior reported in #746. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0166iS8CRLfRiyqCBaYtRDaR
|
Profile summary: |
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.
Closes #746.
Not a 0.24.5 regression (verified)
The report attributed a credential-read break to the 0.24.5 security work. The diff disproves that:
security.py,config.py,models.py(all credential storage/read code) are byte-identical to 0.24.4.auth.pychange in 0.24.5 is only thehttp://warning inverify_credentials()— a different method, not on theload_credentials()path.uv.lockchanged only the youtrack-cli version; no dependency (keyring/pydantic/cryptography) moved.Actual cause: OS keychain behavior — Keychain items are access-bound to the binary that created them, so
uv tool upgrade(which rebuilds the tool venv with a newpythonpath) can cause the OS to deny the new binary access to the saved token.keyring.get_passwordthen returnsNone,load_credentials()returnsNone, and you seeAUTH_004. Re-runningyt auth loginre-stores under the new binary. This is independent of 0.24.5's contents.What this PR does (the actionable part of #746)
Adds
AuthManager.credentials_stored_but_unreadable()and uses it inyt auth statusso the "credentials present but unreadable" case is no longer misreported as "no credentials found":Detection: config records a keyring-backed login (
YOUTRACK_API_KEY=[Stored in keyring]+ base URL) butload_credentials()returnsNone.Tests
tests/test_auth.py::TestCredentialsStoredButUnreadable— flags the placeholder+unreadable case, and does not flag readable creds or a clean/no-creds config. Full suite: 1402 passed.🤖 Generated with Claude Code