The `whoami` command may end in StoreServerError [401] UNAUTHORIZED
Metadata
Current evaluation
Expired-credential handling for whoami was fixed by PR #609, merged as 69df5a9a, so 401 responses now report logged-out status without auto-login.
Resolution: closed resolved
Reason: PR #609 was merged via commit 69df5a9a, adding an allow-login option so whoami handles 401 responses as a logged-out state instead of exposing StoreServerError. Maintainer comments confirm it resolved #594.
Evaluated by: mr-cal-bot
No scores available.
Issue body
This happens when the user is logged in (has local credentials) but those expired.
The solution is to wrap `Store.whoami` (in `store.py`) with the `_store_client_wrapper` decorator. But for this, the decorator should be enhanced.
So `_store_client_wrapper` should be a function that accepts a parameter and returns the real decorator.
All current decorator usage should mutate to `_store_client_wrapper()`, but in `whoami` it should be `_store_client_wrapper(auto_login=False)`.
Then, the code inside the decorator itself should be something like:
```
except craft_store.errors.StoreServerError as error:
if error.response.status_code == 401:
if auto_login:
emit.progress("Existing credentials no longer valid. Trying to log in...")
else:
raise NotLoggedIn()
else:
raise CommandError(str(error)) from error
```
Evaluation history
| Date | Model | Scores | Action | Summary |
|---|---|---|---|---|
| stealth/space-bunny-alpha | — | closed resolved | Expired-credential handling for whoami was fixed by PR #609, merged as 69df5a9a, so 401 responses now report logged-out status without auto-login. | |
| stealth/space-bunny-alpha | — | closed resolved | 401 handling for whoami expired credentials was fixed in canonical/charmcraft#609, merged as 69df5a9a, by disabling automatic login and reporting logged-out status. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Fixed in PR #609 by enhancing the _store_client_wrapper decorator to handle 401 UNAUTHORIZED errors when credentials expire. The update triggers auto-login or raises NotLoggedIn. Remaining error conversion refactoring is deferred. | |
| qwen/qwen3.6-35b-a3b | — | — | Fixed in PR #609. The _store_client_wrapper decorator was enhanced to properly handle 401 UNAUTHORIZED errors when local credentials expire. The whoami command now correctly manages expired sessions, with remaining technical debt deferred to the craft-cli migration. | |
| qwen3.6-35b-a3b-mtp-q6 | — | — | Resolved in PR #609 by enhancing the _store_client_wrapper decorator to handle 401 UNAUTHORIZED errors when local credentials expire. The whoami command now correctly manages expired sessions, with related error conversion refactoring deferred. |
Update history
No update history recorded yet.
Related work
-
Likely Fixed By:
canonical/charmcraft#609
(confidence 100%)
PR #609 implemented the whoami wrapper change and was merged as 69df5a9a.
Related issues
| Issue | Project | State | Summary | Similarity |
|---|---|---|---|---|
| #609 store: handle store errors in whoami command (CRAFT-701) | charmcraft | merged | Merged in canonical/charmcraft#609 via 3d7474b1 (merge 69df5a9a), adding allow_login so whoami reports logged-out and expired-credential errors without automatic login. |