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

feat(jsonrpc): Implement backwards compatible structured errors #3517

Closed
2 tasks done
frol opened this issue Oct 22, 2020 · 3 comments
Closed
2 tasks done

feat(jsonrpc): Implement backwards compatible structured errors #3517

frol opened this issue Oct 22, 2020 · 3 comments
Assignees
Labels
A-RPC Area: rpc C-enhancement Category: An issue proposing an enhancement or a PR with one.

Comments

@frol
Copy link
Collaborator

frol commented Oct 22, 2020

  • Rebase fix(rpc): structured errors #3204 to the latest master (moved into a separate issue Implement structured errors in view-client #3518)
  • Adapt JSON RPC responses so they return text old errors based on the new view client detailed errors (the structure and the messages must be IDENTICAL to the previous response messages); to do that we should match the structured error response received from the view client and craft the text of the old error message

This issue should be considered to be resolved once we can merge the proposed changes to the view-client (intorducing detailed programmatic errors instead of string errors), so any errornous response MUST remain the same:

$ http post https://rpc.testnet.near.org jsonrpc=2.0 id=dontcare method=block 'params:=[0]'

{
    "error": {
        "code": -32000,
        "data": "DB Not Found Error: BLOCK HEIGHT: 0 \n Cause: Unknown",
        "message": "Server error"
    },
    "id": "dontcare",
    "jsonrpc": "2.0"
}

We are going to expose those structured errors via RPC side-by-side with the current text errors as part of #2976. We do it in two steps to split the effort and take some time to bikeshed the structure we want to have for the RPC interfaces.

Implementation Notes

I propose to implement .to_old_error_message() -> String method for every error type we introduced for the view-client, so ultimately, on the jsonrpc side we can just call .to_old_error_message() on the ViewClientError and it would just recursively construct the error message for us.

@frol frol added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-RPC Area: rpc labels Oct 22, 2020
@bowenwang1996
Copy link
Collaborator

Rebase #3204 to the latest master

@frol I think this is not a trivial task and it may be worth creating a separate issue for it. I can help with the task.

@frol
Copy link
Collaborator Author

frol commented Oct 22, 2020

@bowenwang1996 I see. Here you go #3518 😄

@frol
Copy link
Collaborator Author

frol commented May 1, 2021

This is resolved in a set or PRs: #3805, #3861, #3944, #4079, #4119, #4180, #4200, and #4213.

The next step is #2976

@frol frol closed this as completed May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-RPC Area: rpc C-enhancement Category: An issue proposing an enhancement or a PR with one.
Projects
None yet
Development

No branches or pull requests

3 participants