From 0c0e2c24374e64a06b43a4957391d890e0a72ea1 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 29 Mar 2024 04:28:01 +0000 Subject: [PATCH] fix: ignore error when key not found in keys delete (backport #1312) (#1315) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: ignore error when key not found in keys delete (#1312) * fix(client/keys): don't return when key not found in keys delete (#18562) * chore: update CHANGLOG.md Signed-off-by: 170210 --------- Signed-off-by: 170210 Co-authored-by: Julián Toledano (cherry picked from commit e5709f3324a4b766faa56fc51aed4a9d6b62d4c6) # Conflicts: # CHANGELOG.md * Update CHANGELOG.md --------- Co-authored-by: 170210 <85928898+170210@users.noreply.github.com> Co-authored-by: Youngtaek Yoon --- CHANGELOG.md | 1 + client/keys/delete.go | 3 ++- client/keys/delete_test.go | 3 +-- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e2cb976818..3e6d979bdf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -52,6 +52,7 @@ Ref: https://keepachangelog.com/en/1.0.0/ * (client) [\#1303](https://github.com/Finschia/finschia-sdk/pull/1303) fix possible overflow in BuildUnsignedTx * (types) [\#1299](https://github.com/Finschia/finschia-sdk/pull/1299) add missing nil checks * (x/staking) [\#1301](https://github.com/Finschia/finschia-sdk/pull/1301) Use bytes instead of string comparison in delete validator queue (backport cosmos/cosmos-sdk#12303) +* (client/keys) [#1312](https://github.com/Finschia/finschia-sdk/pull/1312) ignore error when key not found in `keys delete` ### Removed diff --git a/client/keys/delete.go b/client/keys/delete.go index 8f5c9e695e..a7fb35158d 100644 --- a/client/keys/delete.go +++ b/client/keys/delete.go @@ -37,7 +37,8 @@ private keys stored in a ledger device cannot be deleted with the CLI. for _, name := range args { info, err := clientCtx.Keyring.Key(name) if err != nil { - return err + cmd.PrintErrf("key %s not found\n", name) + continue } // confirm deletion, unless -y is passed diff --git a/client/keys/delete_test.go b/client/keys/delete_test.go index afb1c0fb0f..2a4bf397fd 100644 --- a/client/keys/delete_test.go +++ b/client/keys/delete_test.go @@ -51,8 +51,7 @@ func Test_runDeleteCmd(t *testing.T) { ctx := context.WithValue(context.Background(), client.ClientContextKey, &clientCtx) err = cmd.ExecuteContext(ctx) - require.Error(t, err) - require.EqualError(t, err, "blah.info: key not found") + require.NoError(t, err) // User confirmation missing cmd.SetArgs([]string{