-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
SDK Errors UX #14070
Comments
This is kind of needed to preserve a unique mapping of The whole error code / code space idea was a design from tendermint that pre-dated me and the cosmos sdk. Tendermint wanted unique error codes for all failures. In practice, no one ever uses them and the produce a lot of burden on app developers. People heavily rely on the error messages, but the error codes can be broken into 3 groups:
The first two are handled in ante handlers. We could simply let the application return normal Go errors ( This would be a consensus breaking change but I challenge you to find one client that checks the error codes beyond |
I think this is how it is done now. Or at least wasmd does this since ages. Actually, staking does the same. Yes, we have to skip 0 and 1 and then add a few lines to create a list of all error codes. It is a bit annoying but I don't see much simplification as long as we want meaningful code ids. As I said above, I think there was a lot of demand on providing these abc error codes and no usage. Happy to see them go. |
I'm unaware of any application that uses the codespace or inspects it for anything. I'd propose removing them altogether since users only care about the error message |
I don't think we should remove the ability to register errors because that would break too much code, but we can point users away from it. I think providing a good set of common errors in The gRPC status codes are already in common usage when people implement query handlers so if they're reusable elsewhere it's one API to learn. And they're also pretty well thought out IMHO (for instance But having reusable SDK specific errors would also be good. I just think they should be more well thought out and minimal than all the ones currently registered in types/errors. |
I insist on all new Osmosis code that we never register errors, because it is an enormous overhead / barrier to safe patch releases. I advocate for removing the sdk error registration entirely for now, and only revisit it if someone is going to make a plan to ensure clients can actually use them (and gather what they really care about being merkelized) |
This <3 To re-iterate, no one really uses codespaces or codes for that matter...maybe they use codespaces, I'm not sure. But codes are really meaningless. So that's why I proposed we remove registration and just rely on good messaging and clear codespaces as we do now. Removing the unnecessary registration process. |
What do codespaces get us? |
Knowing where the error came from. Like which module or package. Otherwise a invalid logic could mean 20 different things |
I use codespaces! There are certain codes/spaces combos that denote no fee was taken. These are used in the earlier set of blocks, but still useful if theres a very specific scenario. |
I assume these are from sdk/auth module? Can you list the ones you care about? I think if we have even a dozen cases people care about, we can keep those, but in general when writing new modules, they just return generic error that has codespace somehow (how to do that in least invasive way) but not a specific code per error. |
What I'm getting from this discussion is we want code spaces, which could be inferred from the module name, if there is a need for more granularity the application developer can register another code space (staking/delegation, etc..). Error codes are not used fully because there is not a design flow we are aware that uses them. We should remove error codes and simply return a default number. |
What will be the API for just using the code space? |
From a relayer perspective (i.e., a client for the SDK/app) we typically match on error messages. Examples:
In general, dealing with the above error messages is very brittle and feels ad-hoc. In an ideal world, messages would be typed and encoded in a .proto file so we can consume/match on them in some automated way instead of string matching. But I guess a tradeoff of that approach is code evolving slower. |
|
@adizere Why didn't you use the existing error codes? There are codes for fee issues and for sequence mismatch. If you don't currently use codes to detect this, it is a bit of a proof that they don't help client. |
@ethanfrey The ones I watch for are sdk/8 and sdk/32 |
heavily agree here, you should not be matching strings for errors. |
Two reasons:
|
My proposal here is:
This simplifies and possibly removes most of the custom errors in modules |
@tac0turtle Would the error codes be unique across the code? or only unique within the module? |
error codes can only be guaranteed to be unique within the module |
I am trying to understand your comment here You say there is a change of error code for a given action between sdk 0.44.5 and 0.44.6? |
I quickly checked the commits between 0.44.5 and 0.44.6 and there was no new error defined nor updated. |
I was thinking the error code is only the module, not specific to an error as this is unneeded information in consensus |
we worked on errorsv2 that removed a lot of functionality in the errors pkg and made it zerodeps. users dont need to register errors anymore and i can see the sdk moving away from using sdk errors going forward |
Context
Error registration in modules has proven to be pretty cumbersome, e.g. needing to avoid certain integers.
Proposal
There are two proposals floating around:
Specifically, a module would define it's own codespace (this can even be simply inferred from the store key). The question is, does a module define it's own errors or does it just simply use the gRPC ones?
/cc @tac0turtle @aaronc
The text was updated successfully, but these errors were encountered: