diff --git a/CHANGELOG.md b/CHANGELOG.md index 7957b3edda..6dced1938d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -38,6 +38,10 @@ Ref: https://keepachangelog.com/en/1.0.0/ ## [Unreleased] +### Bug Fixes + +* (x/authz) [#24638](https://github.com/cosmos/cosmos-sdk/pull/24638) Fixed a minor bug where the grant key was cast as a string and dumped directly into the error message leading to an error string possibly containing invalid UTF-8. + ### Deprecated * (x/nft) [#24575](https://github.com/cosmos/cosmos-sdk/pull/24575) Deprecate the `x/nft` module in the Cosmos SDK repository. This module will not be maintained to the extent that our core modules will and will be kept in a [legacy repo](https://github.com/cosmos/cosmos-legacy). diff --git a/x/authz/keeper/keeper.go b/x/authz/keeper/keeper.go index 12334ef2aa..ad0a93ba4c 100644 --- a/x/authz/keeper/keeper.go +++ b/x/authz/keeper/keeper.go @@ -3,6 +3,7 @@ package keeper import ( "bytes" "context" + "encoding/hex" "fmt" "strconv" "time" @@ -241,7 +242,7 @@ func (k Keeper) DeleteGrant(ctx context.Context, grantee, granter sdk.AccAddress skey := grantStoreKey(grantee, granter, msgType) grant, found := k.getGrant(ctx, skey) if !found { - return errorsmod.Wrapf(authz.ErrNoAuthorizationFound, "failed to delete grant with key %s", string(skey)) + return errorsmod.Wrapf(authz.ErrNoAuthorizationFound, "failed to delete grant with key %s", hex.EncodeToString(skey)) } if grant.Expiration != nil { diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index d4c8a0b8a3..233c3c7ea4 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -137,6 +137,10 @@ func (s *TestSuite) TestKeeper() { s.T().Log("verify removing non existing authorization returns error") err = s.authzKeeper.DeleteGrant(ctx, granterAddr, granteeAddr, "abcd") s.Require().Error(err) + + s.T().Log("verify removing non existing authorization returns error with grant key in hex") + err = s.authzKeeper.DeleteGrant(ctx, granterAddr, granteeAddr, "abcd") + s.Require().Equal("failed to delete grant with key 0114a58856f0fd53bf058b4909a21aec019107ba610114a58856f0fd53bf058b4909a21aec019107ba610061626364: authorization not found", err.Error()) } func (s *TestSuite) TestKeeperIter() {