neo-go
neo-go copied to clipboard
discrepancy in http return codes for RPC server between C# node and Go node on error
Current Behaviour
curl -i --location 'https://rpc10.n3.nspcc.ru:10331' --header 'Content-Type: text/plain' --data '{
"jsonrpc": "2.0",
"id": 1,
"method": "getapplicationlog",
"params": ["0xacaa380861ecbd458a924256f3ab798d89263d43d3340014002eccab2542da31"]
}'
**HTTP/2 422**
Expected Behavior
status code 200 like C#
curl -i --location 'http://seed1.neo.org:10332' --header 'Content-Type: text/plain' --data '{
"jsonrpc": "2.0",
"id": 1,
"method": "getapplicationlog",
"params": ["0xacaa380861ecbd458a924256f3ab798d89263d43d3340014002eccab2542da31"]
}'
**HTTP/1.1 200 OK**
Similarly an invalid invokescript
returns 200 on C# and 400 with neo-go.
Possible Solution
change status code to 200
From https://www.rfc-editor.org/rfc/rfc4918#section-11.2
The 422 (Unprocessable Content) status code indicates that the server understands the content type of the request content (hence a 415 (Unsupported Media Type) status code is inappropriate), and the syntax of the request content is correct, but it was unable to process the contained instructions.
I assume the reason came from the bold part, but is that really fair? It actually is able to process the instructions in the request, its just that it couldn't find what was asked for. This feels like throwing a 422 just because you called getnep17balances
expecting there to be some but there were none
Your Environment
0.106.3