Skip to content

feat: add user confirmation for keys rm command#2452

Open
mootz12 wants to merge 1 commit intomainfrom
issues/2420-confirm-key-rm
Open

feat: add user confirmation for keys rm command#2452
mootz12 wants to merge 1 commit intomainfrom
issues/2420-confirm-key-rm

Conversation

@mootz12
Copy link
Contributor

@mootz12 mootz12 commented Mar 16, 2026

What

Add a confirmation prompt when deleting keys. The confirmation prompt can be bypassed with a --force flag. Confirmation also works by piping y into stdin.

$ stellar keys rm rmtest           
⚠️  Are you sure you want to remove the key 'rmtest'? This action cannot be undone. (y/N)
y
ℹ️  Removing the key's cli config file
$ stellar keys rm rmtest --force          
ℹ️  Removing the key's cli config file
$ stellar keys rm rmtest      
⚠️  Are you sure you want to remove the key 'rmtest'? This action cannot be undone. (y/N)
N
❌ error: removal cancelled by user

Why

Closes: #2420

Known limitations

None

@mootz12 mootz12 requested review from a team and Copilot March 16, 2026 17:24
@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Mar 16, 2026
@fnando
Copy link
Member

fnando commented Mar 16, 2026

This is a breaking change, so I think we should hold it until the next protocol release.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a safety confirmation step to stellar keys rm to prevent accidental identity deletion, with a --force escape hatch for non-interactive use. This aligns CLI behavior with the request in #2420 for destructive-action confirmation.

Changes:

  • Add interactive confirmation handling to keys rm, plus a new --force flag to skip confirmation.
  • Add integration tests covering confirmation-required behavior and --force.
  • Update user-facing docs/help to mention --force and reflect the new behavior.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
cookbook/stellar-keys.mdx Updates the “Remove the Identity” example command.
cmd/soroban-cli/src/commands/keys/rm.rs Implements confirmation prompt + --force flag for key removal.
cmd/crates/soroban-test/tests/it/integration/keys.rs Adds integration tests for confirmation and --force.
FULL_HELP_DOCS.md Documents the new --force option in generated help.

You can also share your feedback on Copilot code review. Take the survey.


```bash
stellar keys rm carol
stellar keys rm carol --force
Comment on lines +43 to +47
if stdin.is_terminal() {
print.warnln(format!(
"Are you sure you want to remove the key '{}'? This action cannot be undone. (y/N)",
self.name
));
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One ask otherwise lgtm.

if stdin.is_terminal() {
print.warnln(format!(
"Are you sure you want to remove the key '{}'? This action cannot be undone. (y/N)",
self.name
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to show the key path?

We show the key path during key creation and I think it would be helpful to follow suit here too. For example:

✅ Key saved with alias asdfasdf in "/Users/leighmcculloch/.config/stellar/identity/asdfasdf.toml"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Backlog (Not Ready)

Development

Successfully merging this pull request may close these issues.

stellar keys rm should require confirmation before deleting a key

4 participants