Report keychain delete failures instead of succeeding (CLS-1267) #314
Loading…
Reference in a new issue
No description provided.
Delete branch "stephen/cls-1267-keychain-delete"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
CLS-1267 item 3.
auth::delete_tokenignored every keychain delete error and succeeded after removing the file entry, so logout and session clear could report success while a locked keychain still held the secret.Behaviour
NoStorageAccess(keychain locked or access denied): the file entry is removed, then the delete fails, so the caller keeps the profile or session selectable and running it again finishes the job.PlatformFailureon macOS and Windows, where a keychain always exists (keyring maps a locked keychain from a headless session or a denied prompt to it): same, fails.PlatformFailureon Linux: warns once per run and succeeds, so logout still works where keyutils is blocked, e.g. in a container with the default seccomp profile that falls back to the file store.fj auth logoutnow deletes the secrets first (each one attempted) and removes the host fromhosts.tomlonly if all succeeded (Hosts::remove_after_cleanup), so a failed delete leaves the host configured for a retry. Before, it removed and saved the host first, which would have made the retry impossible.Known limit (self-review round 3, left as is)
On Linux a
PlatformFailurecan also be anEPERMfrom a seccomp-restricted environment that does hold a keyutils credential from elsewhere. fj cannot tell that from "no keyring" with the error the backend gives, so it warns and succeeds there. The warning is printed once so it is not silent.User-visible: logout and session clearing can now fail with a keychain error where they used to say success. That is the point of the item; decided as option (a) with the lead.
Tests: mock keychain for each error class and both platform settings, a profile-key redaction check, and the host-retained-on-failure behaviour. clippy on this host's newer toolchain stops at an existing lint in
src/cli/pr_line_comment.rs, untouched here. May overlapsrc/cli/auth.rswith 2b-iv; the edit is confined tologout.Not in this PR: deleting the previous generation's secrets when a profile is replaced (
profiles::store,fjord_profiles::login) does not exist today, so replacement leaves the old credential behind regardless of keychain errors. That needs its own change with a persisted cleanup identity; it belongs with the held replacement-lock PR (CLS-1267 item 2) and I will note it on CLS-1267.Automated Codex review (read-only) of head
79107b3998.Medium CHANGELOG.md:11. Invariant: replacement must retain cleanup identity until old secrets are deleted, and release notes must match behavior (standards 11 and 14). The claimed profile-replacement fix is absent.
profiles::storeandfjord_profiles::loginpublish a new generation without callingdelete_tokenfor the previous generation. On a normal PAT refresh with a pasted token or repeated Fjord login, the old credential remains in storage while replacement reports success. Subsequent logout knows only the new generation, so it cannot remove that old secret. This belongs here because the PR explicitly claims replacement cleanup now reports failures. Implement cleanup with a persisted retry identity for both profile types, or remove replacement from the claimed scope and track that missing behavior separately.Low src/auth/mod.rs:369. Edge case, accepted deferral: the PR body's “Known limit” still applies: Linux
PlatformFailurecan represent denied access to an existing credential. The warning-and-success branch can therefore leave a secret behind. No new evidence warrants making this blocking. Retain the documented follow-up to distinguish backend absence from access failure.BLOCKING: 1
Reviewed head
79107b3998at 2026-11-11T15:33:55Z by codex exec (read-only sandbox).Automated Codex review (read-only) of head
be847b1b31.No new correctness, security, or failure-path problems found.
src/auth/mod.rs:376, edge case, accepted deferral. Invariant: successful deletion confirms the secret is gone. LinuxPlatformFailurestill permits success when a restricted environment cannot delete an existing keyutils credential. This is the PR body's documented “Known limit,” unchanged by this review. A follow-up needs backend error discrimination or persisted cleanup identity to support reliable retries.BLOCKING: 0
Reviewed head
be847b1b31at 2026-11-11T15:36:43Z by codex exec (read-only sandbox).Automated Codex review (read-only) of head
a48954410d.src/auth/mod.rs:370, edge case, accepted deferral: The invariant “successful logout confirms secret removal” remains qualified by the PR body’s Known limit. LinuxPlatformFailurecan represent blocked access to an existing keyutils credential. In that case, logout warns and succeeds while the credential remains. Follow-up: distinguish backend absence from access failure where possible, or retain cleanup identity for a later retry.No additional correctness, security, or failure-path problems found in the diff or its callers.
BLOCKING: 0
Reviewed head
a48954410dat 2026-11-11T15:59:36Z by codex exec (read-only sandbox).