Skip to content
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

Fall back when keyring is locked #7037

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/poetry/utils/password_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,14 @@ def get_credential(
return default

import keyring
import keyring.errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is unnecessary.


for name in names:
credential = keyring.get_credential(name, username)
try:
credential = keyring.get_credential(name, username)
except keyring.errors.KeyringLocked:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is missing the #3012 error which is common for headless servers.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like no retry should happen, even with different service names, when getting a KeyringLocked, but I am not sure that behavior is appropriate for all the other KeyringError subclasses.

self._is_available = False
break
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This flow-control doesn't make sense (we shouldn't abort trying all names) -- instead, defaulting credential to None and logging make more sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the keyring is locked because the user canceled, asking them again and again is not very good UX. A single poetry install command might prompt the user a hundred times...

if credential:
return HTTPAuthCredential(
username=credential.username, password=credential.password
Expand Down