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

JSONRPC request with no 'method' but with 'id' #60

Open
clcconan opened this issue Apr 28, 2023 · 2 comments
Open

JSONRPC request with no 'method' but with 'id' #60

clcconan opened this issue Apr 28, 2023 · 2 comments

Comments

@clcconan
Copy link

A request like this, {"jsonrpc": "2.0", "params": [42, 23], "id": 1}.
Should we send back a error response with id?

@nicreuss
Copy link
Contributor

If I understand the JSON-RPC 2.0 specification correctly, when a request is missing the mandatory method field, the response should indicate an invalid request error as shown below.

Request:

{"jsonrpc": "2.0", "params": [42, 23], "id": 1}

Response:

{"jsonrpc": "2.0", "id": 1, "error": {"code": -32600, "message": "Invalid Request"}}

I have some changes in a fork of this repo which relate to error messages in the mjson jsronrpc handler. I will consider making a pull request.

@clcconan
Copy link
Author

clcconan commented May 4, 2023

I have the same understand with you.
As you show, if a request has the correct 'id' item, the response will also has a correct 'id' item, no matter if the request has a 'method' item.
But if I use the mjson correctly, now the response will not response with the correct request 'id' item.
Request:

{"jsonrpc": "2.0", "params": [42, 23], "id": 1}
now Response:

{"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}, "id": null}
or {"jsonrpc": "2.0", "error": {"code": -32600, "message": "Invalid Request"}}

expect Response:
{"jsonrpc": "2.0", "id": 1, "error": {"code": -32600, "message": "Invalid Request"}}

Sorry, The new commit '#61' seems fixed this issues, thanks a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants