Keyring failures give bad error messages
Metadata
Current evaluation
Keyring failures now raise craft-store's KeyringUnlockError with clearer messaging, fixed by PR #390 (commit d87f1bd).
Resolution: closed resolved
Reason: PR #390 was merged as commit d87f1bd, translating underlying keyring failures into the clearer KeyringUnlockError.
Evaluated by: mr-cal-bot
No scores available.
Issue body
I'm running on a headless machine, and apparently there is something wrong with my exported credential.
However, when I try to do something, the error message is very unhelpful:
```
$ charmcraft names
charmcraft internal error: InitError('Failed to create the collection: Prompt dismissed..')
Full execution log: '/home/jameinel/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220725-102753.314065.log'
```
```
$ charmcraft version
1.7.1
$ snap info charmcraft
name: charmcraft
summary: The charming tool
publisher: Canonical✓
store-url: https://snapcraft.io/charmcraft
license: Apache-2.0
description: |
Charmcraft enables charm creators to build, publish, and manage charmed operators for Kubernetes,
metal and virtual machines.
commands:
- charmcraft
snap-id: gcqfpVCOUvmDuYT0Dh5PjdeGypSEzNdV
tracking: latest/stable
...
```
The full execution log is:
```
2022-07-25 10:27:53.314 Starting charmcraft version 1.7.1
2022-07-25 10:27:53.314 Raw pre-parsed sysargs: args={'help': False, 'verbose': False, 'quiet': False, 'trace': False, 'project_dir': None} filtered=['names']
2022-07-25 10:27:53.314 General parsed sysargs: command='names' args=[]
2022-07-25 10:27:53.314 Couldn't find config file '/home/jameinel/dev/juju/juju-qa-jenkins/charmcraft.yaml'
2022-07-25 10:27:53.315 Command parsed sysargs: Namespace()
2022-07-25 10:27:53.315 System details: OSPlatform(system='ubuntu', release='20.04', machine='x86_64'); Environment: None
2022-07-25 10:27:53.389 Retrieving credentials for 'charmcraft' on 'api.charmhub.io' from keyring 'SecretService Keyring'.
2022-07-25 10:27:53.411 Unhandled exception raised when retrieving credentials: InitError('Failed to create the collection: Prompt dismissed..')
2022-07-25 10:27:53.411 Credentials not found. Trying to log in...
2022-07-25 10:27:53.434 charmcraft internal error: InitError('Failed to create the collection: Prompt dismissed..')
2022-07-25 10:27:53.436 Traceback (most recent call last):
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/util.py", line 48, in send_and_get_reply
2022-07-25 10:27:53.436 raise DBusErrorResponse(resp_msg)
2022-07-25 10:27:53.436 jeepney.wrappers.DBusErrorResponse: [org.freedesktop.DBus.Error.UnknownMethod] ('No such interface “org.freedesktop.DBus.Properties” on object at path /org/freedesktop/secrets/collection/login',)
2022-07-25 10:27:53.436
2022-07-25 10:27:53.436 The above exception was the direct cause of the following exception:
2022-07-25 10:27:53.436 Traceback (most recent call last):
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/collection.py", line 161, in get_default_collection
2022-07-25 10:27:53.436 return Collection(connection)
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/collection.py", line 44, in __init__
2022-07-25 10:27:53.436 self._collection.get_property('Label')
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/util.py", line 67, in get_property
2022-07-25 10:27:53.436 (signature, value), = self.send_and_get_reply(msg)
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/util.py", line 52, in send_and_get_reply
2022-07-25 10:27:53.436 raise ItemNotFoundException('Item does not exist!') from resp
2022-07-25 10:27:53.436 secretstorage.exceptions.ItemNotFoundException: Item does not exist!
2022-07-25 10:27:53.436
2022-07-25 10:27:53.436 During handling of the above exception, another exception occurred:
2022-07-25 10:27:53.436 Traceback (most recent call last):
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/keyring/backends/SecretService.py", line 61, in get_preferred_collection
2022-07-25 10:27:53.436 collection = secretstorage.get_default_collection(bus)
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/collection.py", line 163, in get_default_collection
2022-07-25 10:27:53.436 return create_collection(connection, 'Default',
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/secretstorage/collection.py", line 145, in create_collection
2022-07-25 10:27:53.436 raise PromptDismissedException('Prompt dismissed.')
2022-07-25 10:27:53.436 secretstorage.exceptions.PromptDismissedException: Prompt dismissed.
2022-07-25 10:27:53.436
2022-07-25 10:27:53.436 During handling of the above exception, another exception occurred:
2022-07-25 10:27:53.436 Traceback (most recent call last):
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/charmcraft/main.py", line 167, in main
2022-07-25 10:27:53.436 retcode = dispatcher.run()
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/craft_cli/dispatcher.py", line 406, in run
2022-07-25 10:27:53.436 return self._loaded_command.run(self._parsed_command_args)
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/charmcraft/commands/store/__init__.py", line 390, in run
2022-07-25 10:27:53.436 result = store.list_registered_names()
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/charmcraft/commands/store/store.py", line 165, in error_decorator
2022-07-25 10:27:53.436 self.login()
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/charmcraft/commands/store/store.py", line 210, in login
2022-07-25 10:27:53.436 return self._client.login(**kwargs)
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/charmcraft/commands/store/client.py", line 74, in login
2022-07-25 10:27:53.436 return super().login(*args, **kwargs)
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/craft_store/base_client.py", line 130, in login
2022-07-25 10:27:53.436 self._auth.ensure_no_credentials()
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/craft_store/auth.py", line 131, in ensure_no_credentials
2022-07-25 10:27:53.436 if self._keyring.get_password(self.application_name, self.host) is not None:
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/keyring/backends/SecretService.py", line 78, in get_password
2022-07-25 10:27:53.436 collection = self.get_preferred_collection()
2022-07-25 10:27:53.436 File "/snap/charmcraft/978/lib/keyring/backends/SecretService.py", line 63, in get_preferred_collection
2022-07-25 10:27:53.436 raise InitError("Failed to create the collection: %s." % e)
2022-07-25 10:27:53.436 keyring.errors.InitError: Failed to create the collection: Prompt dismissed..
2022-07-25 10:27:53.436 Full execution log: '/home/jameinel/snap/charmcraft/common/cache/charmcraft/log/charmcraft-20220725-102753.314065.log'
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Keyring failures now raise craft-store's KeyringUnlockError with clearer messaging, fixed by PR #390 (commit d87f1bd). | |
| stealth/space-bunny-alpha | — | closed resolved | Fixed in craft-store#390 via commit d87f1bd and released in 3.4.0: keyring initialization failures now raise KeyringUnlockError instead of leaking internal errors. | |
| stealth/space-bunny-alpha | — | closed resolved | Unhelpful keyring errors were addressed in craft-store PR #390 (commit d87f1bd), which wraps keyring failures as KeyringUnlockError. | |
| qwen/qwen3.6-35b-a3b | — | — | Transferred to craft-store for generic keyring error handling. Closed and superseded by internal Jira tickets CRAFT-5223 and CRAFT-5224. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by transfer to craft-store for a generic fix. The library will now catch keyring failures and raise proper error messages for all dependent projects. | |
| qwen/qwen3.6-35b-a3b | — | — | Superseded by transfer to the craft-store repository, where generic keyring error handling will be implemented for all dependent projects. Closed and tracked via internal Jira tickets CRAFT-5223 and CRAFT-5224. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/craft-store#390
(confidence 100%)
Merged fix for improving keyring failure messages.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #390 fix(auth): error more nicely on keyring errors | craft-store | merged | Merged PR #390 (commit d87f1bd) broadens keyring error handling, wrapping more keyring failures as KeyringUnlockError. Fixes #58 and ships in craft-store 3.4.0. | |
| #75 auth: handle keyring unlocking errors | craft-store | merged | Merged PR #75 as commit 74a2ed4, adding keyring unlock error handling that raises a Craft-store error instead of exposing the backend exception. | |
| #901 Charmcraft login on remote device has unhelpful error message | charmcraft | closed | Superseded by canonical/craft-store#58 and fixed there through PR #390 (d87f1bd), which converts keyring initialization failures into KeyringUnlockError. | |
| #38 auth: avoid MemoryKeyring in keyring and raise appropriately (CRAFT-771) | craft-store | merged | Merged in canonical/craft-store#38 via d7ee75f, preventing automatic MemoryKeyring selection and raising NoKeyringError during StoreClient initialization when no keyring exists. |