[cli] Fix rotate-key profile saving without an existing config#20184
Open
plutohan wants to merge 1 commit into
Open
[cli] Fix rotate-key profile saving without an existing config#20184plutohan wants to merge 1 commit into
plutohan wants to merge 1 commit into
Conversation
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.
Description
Fixes #9547.
aptos key rotate-key --save-to-profile <name>failed with a config error when no config file (or default profile) existed, following the solution sketched in the issue:CliConfigwhen none exists;save()already creates the.aptosfolder and config file.How Has This Been Tested?
cargo check -p aptospasses. Manually traced all three failure paths againstCliConfig/ProfileOptionsin aptos-cli-common.Key Areas to Review
The
ConfigNotFoundErrormatch when building the new profile: other errors still propagate, only the missing-profile case falls back to defaults.Type of Change
Which Components or Systems Does This Change Impact?
Checklist
Note
Low Risk
Localized CLI post-rotation config path; no on-chain or auth logic changes, with explicit propagation of non-missing-config errors.
Overview
Fixes
aptos key rotate-key --save-to-profilewhen there is no.aptosconfig or default profile yet.Pre-rotation checks only load config to reject duplicate profile names when a config file already exists; missing config is allowed.
After a successful rotation, saving uses an existing config or
CliConfig::default(), thenconfig.save()creates the file. The new profile copies settings from the current profile whenprofile()succeeds, and usesProfileConfig::default()only when the error isConfigNotFoundError; other config errors still fail.Reviewed by Cursor Bugbot for commit efd904f. Bugbot is set up for automated code reviews on this repo. Configure here.