Skip to content
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

x/authz module specific errors should be registered #11577

Closed
dalmirel opened this issue Apr 7, 2022 · 0 comments · Fixed by #11670
Closed

x/authz module specific errors should be registered #11577

dalmirel opened this issue Apr 7, 2022 · 0 comments · Fixed by #11670
Assignees

Comments

@dalmirel
Copy link

dalmirel commented Apr 7, 2022

As a part of model based testing audit of the authz module, code inspection has been done in order to find issues or possible improvements in code.

Version:
master (commit: 8800d2e)
auditing is performed for tag: v0.46.0-alpha4 (commit: 354faa8)

After analysis of error handling, I saw that there were no module errors registered and used in error.go.

With registration of module error we would define globally unique SDK error with registered codespace and code, also module errors can be further wrapped to provide more details for failed execution.
Also: sdk errors package allows ABCI Info do be extracted for registered errors – the ones that are not registered, are declared as from undefined codespace, as as internal error…

Here are several recommendations for more errors that could be registered and lines of code where they could be used. More thorough analysis should be done, however.

  • ErrNoAuthorizationFound
    ErrNoAuthzorizationFound = sdkerrors.Register(ModuleName, 2, "authorization not found")
    Would be used in
    return sdkerrors.ErrNotFound.Wrap("authorization not found")

    and in line and several more places, in the following way:
    return sdkerrors.Wrapf(authz.ErrNoAuthzorizationFound, "failed to update grant with key %s", string(skey))
  • ErrNegativeMaxTokens (usage in line)
  • ErrUnknownAuthorizationType (usage in line and line)
  • ErrAuthorizationNumOfSigners(usage in line)
  • ...
@julienrbrt julienrbrt self-assigned this Apr 17, 2022
@julienrbrt julienrbrt linked a pull request Apr 18, 2022 that will close this issue
19 tasks
Repository owner moved this from Ready to Done in Cosmos SDK Maintenance Apr 19, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

3 participants