From 26d3559aeb18e1724881838805a925dae02e3340 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Fri, 7 Jul 2023 10:35:40 +0000 Subject: [PATCH] fix(authz): error msg (backport #16869) (#16873) Co-authored-by: atheeshp <59333759+atheeshp@users.noreply.github.com> Co-authored-by: Julien Robert --- CHANGELOG.md | 4 ++++ x/authz/keeper/keeper.go | 3 ++- x/authz/keeper/msg_server_test.go | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index be5c97c17b..fcd285c2a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Improvements + +* (x/authz) [#16869](https://github.com/cosmos/cosmos-sdk/pull/16869) Improve error message when grant not found. + ### Bug Fixes * (x/bank) [#16841](https://github.com/cosmos/cosmos-sdk/pull/16841) Correctly process legacy `DenomAddressIndex` values. diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index fe59013592..282f4e5f10 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -118,7 +118,8 @@ func (k Keeper) DispatchActions(ctx context.Context, grantee sdk.AccAddress, msg grant, found := k.getGrant(ctx, skey) if !found { - return nil, errorsmod.Wrapf(authz.ErrNoAuthorizationFound, "failed to update grant with key %s", string(skey)) + return nil, errorsmod.Wrapf(authz.ErrNoAuthorizationFound, + "failed to get grant with given granter: %s, grantee: %s & msgType: %s ", sdk.AccAddress(granter), grantee, sdk.MsgTypeURL(msg)) } if grant.Expiration != nil && grant.Expiration.Before(now) { diff --git a/x/authz/keeper/msg_server_test.go b/x/authz/keeper/msg_server_test.go index 92e92ad36e..d314c4d2ce 100644 --- a/x/authz/keeper/msg_server_test.go +++ b/x/authz/keeper/msg_server_test.go @@ -331,7 +331,7 @@ func (suite *TestSuite) TestExec() { errMsg: "empty address string is not allowed", }, { - name: "no existing grant", + name: "non existing grant", malleate: func() authz.MsgExec { return authz.NewMsgExec(grantee, []sdk.Msg{msg}) },