-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Incorrect use of ErrNoProposalHandlerExists when the handler returns an error. #13030
Comments
Upon further inspection, it looks like the |
Upon even further inspection, the thing that wraps the legacy handler endpoints returns a So if it's a |
Summary of Bug
In
x/gov/keeper/proposal.go
->SubmitProposal
, for legacy messages, if the handler call returns an error, it is erroneously wrapped as aErrNoProposalHandlerExists
. For example, if the handler returns a code 5, insufficient funds, that gets changed into a code 9, "no handler exists for proposal type".In one of Provenance's unit tests on a governance proposal endpoint, the endpoint/handler returns the error
0stake is smaller than 1stake: insufficient funds
, code 5. But now, the governance module wraps that withErrNoProposalHandlerExists
and it ends up as0stake is smaller than 1stake: insufficient funds: invalid proposal content: no handler exists for proposal type
, code 9.I feel like the error shouldn't be wrapped again. The handler should be trusted to return wrapped errors; if not, it's a bug in that handler. But wrapping them again wipes out any utility there was in returning different codes from the handlers.
This is the offending code:
Version
First noticed in v0.46.0.
Still exists in
main
as of commit6af89d6ce3f43e8a67ea2ee93c5a49e395ebd09d
Wed Aug 24 23:13:11 2022 +0200
.Steps to Reproduce
Submit a governance proposal that will fail when it's handler is called.
The text was updated successfully, but these errors were encountered: