From 52b22f9a6d4abd610382f2b186c7b09b7fd25b07 Mon Sep 17 00:00:00 2001 From: 170210 <85928898+170210@users.noreply.github.com> Date: Wed, 27 Mar 2024 18:32:17 +0900 Subject: [PATCH] fix: ignore error when key not found in keys delete (#1312) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * 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 --- CHANGELOG.md | 18 ++++++++++++++++++ client/keys/delete.go | 3 ++- client/keys/delete_test.go | 3 +-- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index eb197ca3e7..b0b8272b15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,11 +43,29 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### Improvements ### Bug Fixes +<<<<<<< HEAD * (x/auth) [#1281](https://github.com/Finschia/finschia-sdk/pull/1281) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. (backport #1274) * (x/foundation) [\#1283](https://github.com/Finschia/finschia-sdk/pull/1283) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic (backport #1277) * (x/collection) [\#1282](https://github.com/Finschia/finschia-sdk/pull/1282) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis (backport #1276) * (x/collection) [\#1290](https://github.com/Finschia/finschia-sdk/pull/1290) export x/collection params into genesis (backport #1268) * (x/foundation) [\#1295](https://github.com/Finschia/finschia-sdk/pull/1295) add missing error handling for migration +======= +* chore(deps) [\#1141](https://github.com/Finschia/finschia-sdk/pull/1141) Bump github.com/cosmos/ledger-cosmos-go from 0.12.2 to 0.13.2 to fix ledger signing issue +* (x/auth, x/slashing) [\#1179](https://github.com/Finschia/finschia-sdk/pull/1179) modify missing changes of converting to tendermint +* (x/auth) [#1274](https://github.com/Finschia/finschia-sdk/pull/1274) `ModuleAccount.Validate` now reports a nil `.BaseAccount` instead of panicking. +* (x/collection) [\#1276](https://github.com/Finschia/finschia-sdk/pull/1276) eliminates potential risk for Insufficient Sanity Check of tokenID in Genesis +* (x/foundation) [\#1277](https://github.com/Finschia/finschia-sdk/pull/1277) add init logic of foundation module accounts to InitGenesis in order to eliminate potential panic +* (x/collection, x/token) [\#1288](https://github.com/Finschia/finschia-sdk/pull/1288) use accAddress to compare in validatebasic function in collection & token modules +* (x/collection) [\#1268](https://github.com/Finschia/finschia-sdk/pull/1268) export x/collection params into genesis +* (x/collection) [\#1294](https://github.com/Finschia/finschia-sdk/pull/1294) reject NFT coins on FT APIs +* (sec) [\#1302](https://github.com/Finschia/finschia-sdk/pull/1302) remove map iteration non-determinism with keys + sorting +* (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) +* (x/gov) [\#1304](https://github.com/Finschia/finschia-sdk/pull/1304) fetch a failed proposal tally from proposal.FinalTallyResult in the gprc query +* (x/staking) [\#1306](https://github.com/Finschia/finschia-sdk/pull/1306) add validation for potential slashing evasion during re-delegation +* (client/keys) [#1312](https://github.com/Finschia/finschia-sdk/pull/1312) ignore error when key not found in `keys delete` +>>>>>>> e5709f332 (fix: ignore error when key not found in keys delete (#1312)) ### 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{