Skip to content

Commit

Permalink
fix(x/gov): Return ErrInvalidProposalContent in SubmitProposal when l…
Browse files Browse the repository at this point in the history
…egacy handler returns an error. (backport cosmos#13051) (cosmos#15667)

Co-authored-by: Daniel Wedul <github@wedul.com>
Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
  • Loading branch information
3 people committed Apr 3, 2023
1 parent cb26943 commit f89d955
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
### Bug Fixes

* (x/auth/vesting) [#15383](https://github.com/cosmos/cosmos-sdk/pull/15383) Add extra checks when creating a periodic vesting account.
* (x/gov) [#13051](https://github.com/cosmos/cosmos-sdk/pull/13051) In SubmitPropsal, when a legacy msg fails it's handler call, wrap the error as ErrInvalidProposalContent (instead of ErrNoProposalHandlerExists).

## [v0.46.11](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.46.11) - 2022-03-03

Expand Down
6 changes: 5 additions & 1 deletion x/gov/keeper/proposal.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package keeper

import (
"errors"
"fmt"

"github.com/cosmos/cosmos-sdk/client"
Expand Down Expand Up @@ -54,7 +55,10 @@ func (keeper Keeper) SubmitProposal(ctx sdk.Context, messages []sdk.Msg, metadat
if msg, ok := msg.(*v1.MsgExecLegacyContent); ok {
cacheCtx, _ := ctx.CacheContext()
if _, err := handler(cacheCtx, msg); err != nil {
return v1.Proposal{}, sdkerrors.Wrap(types.ErrNoProposalHandlerExists, err.Error())
if errors.Is(types.ErrNoProposalHandlerExists, err) {
return v1.Proposal{}, err
}
return v1.Proposal{}, sdkerrors.Wrap(types.ErrInvalidProposalContent, err.Error())
}
}

Expand Down

0 comments on commit f89d955

Please sign in to comment.