`keyring.errors.KeyringLocked` is not caught and produces a traceback
Metadata
Current evaluation
Locked keyrings now produce a handled keyring-misconfiguration error instead of a traceback. Fixed by merged PR #170 in commit ee19448.
Resolution: closed resolved
Reason: PR #170 added handling for keyring.errors.KeyringLocked and was merged as commit ee19448, resolving the uncaught traceback reported in #166.
Evaluated by: mr-cal-bot
No scores available.
Issue body
### Bug Description
`craft-store` does not catch `keyring.errors.KeyringLocked` and the user will get a traceback instead of a clean error.
The exception could be handled around [here](https://github.com/canonical/craft-store/blob/cafde972baeed23290ec4a2579b78cffe76368f7/craft_store/auth.py#L193).
### To Reproduce
This was originally produced by ssh'ing into an Ubuntu desktop VM. Gnome-keyring tries to show the unlock request in the GUI (which isn't visible).
Another method:
1. On a machine with gnome-keyring, run `snapcraft login`
2. Lock the keyring
3. Run `snapcraft whoami`
4. Cancel the keyring unlock prompt
### part yaml
_No response_
### Relevant log output
```shell
$ snapcraft whoami
Traceback (most recent call last):
File "/snap/snapcraft/10425/bin/snapcraft", line 8, in <module>
sys.exit(run())
File "/snap/snapcraft/10425/lib/python3.10/site-packages/snapcraft/cli.py", line 258, in run
_run_dispatcher(dispatcher, global_args)
File "/snap/snapcraft/10425/lib/python3.10/site-packages/snapcraft/cli.py", line 230, in _run_dispatcher
dispatcher.run()
File "/snap/snapcraft/10425/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run
return self._loaded_command.run(self._parsed_command_args)
File "/snap/snapcraft/10425/lib/python3.10/site-packages/snapcraft/commands/account.py", line 257, in run
whoami = store.StoreClientCLI().store_client.whoami()
File "/snap/snapcraft/10425/lib/python3.10/site-packages/snapcraft/store/client.py", line 179, in _init_
self.store_client = get_client(ephemeral=ephemeral)
File "/snap/snapcraft/10425/lib/python3.10/site-packages/snapcraft/store/client.py", line 161, in get_client
client = craft_store.UbuntuOneStoreClient(
File "/snap/snapcraft/10425/lib/python3.10/site-packages/craft_store/ubuntu_one_store_client.py", line 47, in _init_
super().__init__(
File "/snap/snapcraft/10425/lib/python3.10/site-packages/craft_store/base_client.py", line 77, in _init_
self._auth = Auth(
File "/snap/snapcraft/10425/lib/python3.10/site-packages/craft_store/auth.py", line 192, in _init_
self._keyring.get_preferred_collection()
File "/snap/snapcraft/10425/lib/python3.10/site-packages/keyring/backends/SecretService.py", line 67, in get_preferred_collection
raise KeyringLocked("Failed to unlock the collection!")
keyring.errors.KeyringLocked: Failed to unlock the collection!
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Locked keyrings now produce a handled keyring-misconfiguration error instead of a traceback. Fixed by merged PR #170 in commit ee19448. | |
| stealth/space-bunny-alpha | — | closed resolved | Locked keyrings now produce a handled keyring-misconfiguration error. Fixed by merged PR #170 in commit ee19448. | |
| qwen/qwen3.6-35b-a3b | — | — | Resolved by catching the uncaught KeyringLocked exception and raising a custom CraftStoreKeyringMissconfigurationError instead. This prevents tracebacks and allows upstream applications to handle the locked keyring state appropriately. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed by catching the KeyringLocked exception and raising a custom CraftStoreKeyringMissconfigurationError, which is already handled gracefully elsewhere. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-store#170
(confidence 100%)
Merged PR #170 directly fixes #166 in commit ee19448.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #170 fix: catch keyring locked error | craft-store | merged | Merged PR #170 added handling for locked keyring errors, fixing #166; merged as commit ee19448. |