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

Inconsistent semantics across methods with optional params and methods with no required params #943

Open
i-infra opened this issue Jan 4, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@i-infra
Copy link

i-infra commented Jan 4, 2024

Describe the bug

Neither the "version" method nor the "get_addresses" method require any parameters. However, these two methods behave differently depending upon whether the the JSON-RPC request includes an (empty) parameters argument. I believe full-service should sanitize / regularize these two cases, or improve the error message returned, as the current behavior is inconsistent and confusing.

To Reproduce

Case: method requires empty parameters object in request.

curl -s http://localhost:9090/wallet/v2 --data '{"method": "get_addresses", "jsonrpc": "2.0", "id": 1 }' -X POST -H 'Content-type: application/json'
{"method":"get_addresses","error":{"code":-32600,"message":"InvalidRequest","data":{"server_error":"\"Could not get value Error(\\\"invalid type: null, expected struct variant JsonCommandRequest::get_addresses\\\", line: 0, column: 0)\"","details":"Could not get value Error(\"invalid type: null, expected struct variant JsonCommandRequest::get_addresses\", line: 0, column: 0)"}},"jsonrpc":"2.0","id":1}

Case: method requires no parameters object in request.

curl -s http://localhost:9090/wallet/v2 --data '{"method": "version", "params":{}, "jsonrpc": "2.0", "id": 1 }' -X POST -H 'Content-type: application/json'
{"method":"version","error":{"code":-32600,"message":"InvalidRequest","data":{"server_error":"\"Could not get value Error(\\\"invalid type: map, expected unit variant JsonCommandRequest::version\\\", line: 0, column: 0)\"","details":"Could not get value Error(\"invalid type: map, expected unit variant JsonCommandRequest::version\", line: 0, column: 0)"}},"jsonrpc":"2.0","id":1}⏎                           

Expected behavior

Should a required parameter not be included in a RPC request, an error message not requiring understanding Rust is returned to the user.

If parameters are optional, the params: {} object can be omitted from the JSON RPC request.

Different error codes should be returned for different scenarios presented here.

Environment (please complete the following information):
Vanilla Ubuntu, latest Full Service release.

Additional context

@i-infra i-infra added the bug Something isn't working label Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant