fix: prevent stale secure-storage credentials after profile logout/remove/rename#221
Merged
felipefreitag merged 5 commits intomainfrom Apr 14, 2026
Merged
Conversation
…move/rename - resolveApiKeyAsync: only query secure storage if profile exists in credentials.json, preventing stale keychain entries from authenticating removed profiles - removeApiKeyAsync: check backend.delete return value and throw on failure instead of silently continuing - removeAllApiKeysAsync: collect backend.delete results and throw if any profile deletion fails, preserving credentials file - renameProfileAsync: check old-name deletion result and roll back the new entry if it fails, preventing partial rename states Closes BU-631 Co-authored-by: Bu Kinoshita <bukinoshita@users.noreply.github.com>
Member
Author
|
@cubic-dev-ai can you review? |
Contributor
@bukinoshita I have started the AI code review. It will take a few minutes to complete. |
Contributor
There was a problem hiding this comment.
2 issues found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/config.ts">
<violation number="1" location="src/lib/config.ts:427">
P2: `removeApiKeyAsync` can throw a misleading secure-storage failure for non-existent profiles because delete is attempted before profile existence is validated.</violation>
<violation number="2" location="src/lib/config.ts:479">
P2: Rename rollback is not verified: failure to delete `newName` is ignored while the error claims rollback succeeded.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
Contributor
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="src/lib/config.ts">
<violation number="1" location="src/lib/config.ts:458">
P2: Retry after partial bulk-delete failure is unrecoverable on macOS and Windows. `backend.delete` returns `false` for already-deleted (non-existent) entries on those platforms, so retrying will re-fail the previously-succeeded profiles too, expanding the failure set every time.
Consider pre-checking with `backend.get()` to only attempt deletion of entries that still exist, or at least make the error message explicit that manual credential-file removal may be required.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
…al bulk delete - Reject nonexistent profile early in `logout` instead of prompting for confirmation - Update credentials.json to remove successfully-deleted profiles on partial bulk failure so retries only re-attempt the ones that actually failed
felipefreitag
approved these changes
Apr 14, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by cubic
Prevents stale credentials in OS secure storage from authenticating removed or renamed CLI profiles. Keeps secure storage and
credentials.jsonin sync, addressing BU-631.credentials.json(blocks auth via stale entries).backend.deletefails on remove; do not update the file to avoid desync.it().Written for commit 00fadec. Summary will update on new commits.