Handle unlock cancellation messages robustly in settings flow

This commit is contained in:
thePR0M3TH3AN committed 2026-02-25 21:35:33 -05:00
1 parent 882cd060fa
commit 073b1065ca
2 files changed
+19 -6

No files matched your search

+5
View File
@@ -109,3 +109,8 @@
- CI `test (ubuntu-latest, 3.10)` failed during test collection because `datetime.UTC` is unavailable on Python 3.10.
- Replaced `datetime.UTC` usage with `timezone.utc` in `src/seedpass/cli/agent.py` and `scripts/ai_tui_agent_test.py`.
- Verified with targeted tests: `src/tests/test_cli_agent_mode.py` and `src/tests/test_ai_tui_agent_harness.py`.
## Settings Unlock Cancellation Robustness (2026-02-26)
- CI showed `test_settings_lock_unlock_cancelled_is_graceful` intermittently receiving a generic exception path instead of `PasswordPromptError` during Settings -> Lock Vault unlock.
- Hardened `handle_settings()` lock flow to treat any exception containing "cancelled by user" as cancellation, printing `Unlock cancelled: ...` instead of a hard failure message.
- Verified with targeted pytest for the failing test.
+14 -6
View File
@@ -1102,12 +1102,20 @@ def handle_settings(password_manager: PasswordManager) -> None:
except PasswordPromptError as exc:
print(colored(f"Unlock cancelled: {exc}", "yellow"))
except Exception as exc:
logging.error(
"Failed to unlock vault from settings: %s",
exc,
exc_info=True,
)
print(colored(f"Failed to unlock vault: {exc}", "red"))
# Some environments can surface cancellation through a
# different exception class; treat the message as cancel.
if "cancelled by user" in str(exc).lower():
logging.warning(
"Unlock cancelled during settings lock flow: %s", exc
)
print(colored(f"Unlock cancelled: {exc}", "yellow"))
else:
logging.error(
"Failed to unlock vault from settings: %s",
exc,
exc_info=True,
)
print(colored(f"Failed to unlock vault: {exc}", "red"))
else:
password_manager.start_background_sync()
getattr(