← Back to issue list

Launchpad: Handle invalid credentials files better

View original Github issue

Metadata

Project
craft-application
Number
#241
Type
issue
State
open
Author
lengau
Labels
Status: Triaged Type: Enhancement
Created
Updated
Closed
—

Current evaluation

Enhancement request (maintainer-filed, triaged) to make Launchpad.login recover from a corrupt/invalid launchpad credentials file by deleting it and re-authenticating, instead of surfacing a raw configparser.NoOptionError internal traceback. Still unaddressed in craft_application/launchpad/launchpad.py.

Suggested action: keep open

Reason: The issue is explicitly triaged (labels 'Status: Triaged', 'Type: Enhancement') and authored by maintainer lengau, with a full traceback showing 'charmcraft internal error: No option \'consumer_key\' in section: \'1\''. Inspection of the current code confirms it is unimplemented: Launchpad.login in craft_application/launchpad/launchpad.py (lines 73-98) calls launchpadlib's login_with with no try/except around it, and RemoteBuildService._get_lp_client (remotebuild.py:250-268) only emits debug messages about the credentials file existence; a repo-wide grep for 'configparser' returns no matches and git log -S shows no fix commit. The requested behaviour is concrete (delete the credentials file and log in again), so it is ready for development, though the exact desired UX (silent retry with re-auth vs. raising a CraftError telling the user to delete the file) is not spelled out.

Evaluated by: mr-cal-bot

Impact: 32 Quick Win: 17 Complexity: 35 Confidence: 88 Actionability: 82

Issue body

### What needs to get done If `Launchpad.login` errors out due to `configparser` issues, try deleting the credentials file and logging in again. ### Why it needs to get done This isn't an acceptable error message: ``` + charmcraft remote-build --verbose --launchpad-accept-public-upload Starting charmcraft, version 2.5.5.post102+g0f95a52 Logging execution to '/root/.local/state/charmcraft/log/charmcraft-20240226-125356.635385.log' remote-build is experimental and is subject to change. Use with caution. charmcraft internal error: No option 'consumer_key' in section: '1' Full execution log: '/root/.local/state/charmcraft/log/charmcraft-20240226-125356.635385.log' Traceback (most recent call last): File "/snap/charmcraft/x1/usr/lib/python3.10/configparser.py", line 791, in get value = d[option] File "/snap/charmcraft/x1/usr/lib/python3.10/collections/__init__.py", line 986, in __getitem__ return self.__missing__(key) # support subclasses that define __missing__ File "/snap/charmcraft/x1/usr/lib/python3.10/collections/__init__.py", line 978, in __missing__ raise KeyError(key) KeyError: 'consumer_key' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "/snap/charmcraft/x1/bin/charmcraft", line 8, in <module> sys.exit(main()) File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/application/main.py", line 150, in main return app.run() File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/application.py", line 465, in run return_code = dispatcher.run() or 0 File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_cli/dispatcher.py", line 487, in run return self._loaded_command.run(self._parsed_command_args) File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/commands/base.py", line 171, in run result = self._run(parsed_args, **kwargs) or result File "/snap/charmcraft/x1/lib/python3.10/site-packages/charmcraft/application/commands/remote.py", line 110, in _run builder = self._services.remote_build File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/services/service_factory.py", line 95, in __getattr__ instance.setup() File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 69, in setup self.lp = self._get_lp_client() File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/services/remotebuild.py", line 202, in _get_lp_client return launchpad.Launchpad.login( File "/snap/charmcraft/x1/lib/python3.10/site-packages/craft_application/launchpad/launchpad.py", line 98, in login launchpadlib.launchpad.Launchpad.login_with( File "/snap/charmcraft/x1/lib/python3.10/site-packages/launchpadlib/launchpad.py", line 700, in login_with return cls._authorize_token_and_login( File "/snap/charmcraft/x1/lib/python3.10/site-packages/launchpadlib/launchpad.py", line 445, in _authorize_token_and_login cached_credentials = credential_store.load( File "/snap/charmcraft/x1/lib/python3.10/site-packages/launchpadlib/credentials.py", line 345, in load return self.do_load(unique_key) File "/snap/charmcraft/x1/lib/python3.10/site-packages/launchpadlib/credentials.py", line 486, in do_load return Credentials.load_from_path(self.filename) File "/snap/charmcraft/x1/lib/python3.10/site-packages/lazr/restfulclient/authorize/oauth.py", line 229, in load_from_path credentials.load(credentials_file) File "/snap/charmcraft/x1/lib/python3.10/site-packages/lazr/restfulclient/authorize/oauth.py", line 205, in load consumer_key = parser.get(CREDENTIALS_FILE_VERSION, "consumer_key") File "/snap/charmcraft/x1/usr/lib/python3.10/configparser.py", line 794, in get raise NoOptionError(option, section) configparser.NoOptionError: No option 'consumer_key' in section: '1' ----- . 2024-02-26 12:53:56 Restoring multipass:ubuntu-22.04-64:tests/spread/smoketests/remote-build:jammy (multipass:ubuntu-22.04-64)... ```

Evaluation history

Date Model Scores Action Summary
stealth/space-bunny-alpha
Impact: 32
Quick Win: 17
Complexity: 35
Confidence: 88
Actionability: 82
keep open Enhancement request (maintainer-filed, triaged) to make Launchpad.login recover from a corrupt/invalid launchpad credentials file by deleting it and re-authenticating, instead of surfacing a raw configparser.NoOptionError internal traceback. Still unaddressed in craft_application/launchpad/launchpad.py.
qwen/qwen3.6-35b-a3b
Impact: 30
Quick Win: 13
Complexity: 40
Confidence: 70
Actionability: 70
keep open Enhancement to handle invalid Launchpad credentials files gracefully by catching configparser errors, deleting the corrupted file, and retrying login.
qwen/qwen3.8-27b
Impact: 35
Quick Win: 24
Staleness: 55
Complexity: 30
Confidence: 75
Support Request: 5
keep open Enhancement to catch configparser errors from invalid Launchpad credentials files and retry login after deleting the file. Triaged by maintainer 2.5 years ago; code in launchpad.py still has no such handling. Inactive for ~7 months.
qwen/qwen3.6-35b-a3b
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 10
keep open Enhancement to improve error handling for invalid Launchpad credentials files, suggesting deletion and re-login instead of crashing with a configparser error. Currently triaged but inactive for over 6 months.
qwen3.6-35b-a3b-mtp-q6
Staleness: 85
Complexity: 20
Confidence: 80
Support Request: 5
close stale Enhancement to improve error handling for invalid Launchpad credentials files. Triaged but inactive for over two years with no progress or recent maintainer engagement.

Update history

No update history recorded yet.

Related issues

No related issues found above the similarity threshold.