Malformed Filecoin RPC calls are not returning error messages

I tried to use the Filecoin APIs, and noticed that most of them are not returning error messages, when the request is malformed. For example the following RPC request is malformed, due to wrong number of params, but the response doesn’t include that information.

curl -v -X POST \
	 -H "Content-Type: application/json" \
	 --data '{ "jsonrpc": "2.0", "method": "Filecoin.StateListMiners", "params": [ ], "id": 1 }' \	 ''

Trying the same RPC request on a Filecoin node results in:

{"jsonrpc":"2.0","id":1,"error":{"code":-32602,"message":"wrong param count (method 'Filecoin.StateListMiners'): 0 != 1"}}

This could potentially make it harder for developers to build apps on Infura.

1 Like

Hi @nonsense - welcome to the Infura community! Thanks for the suggestion - we’ll definitely take that into consideration!

Thanks for the feedback @nonsense!

We have just updated this and you will now see the JSON-RPC error payload. Note that you will now also see this return a 200 response code as opposed to the 500 returned by lotus. This is more typical of a JSON-RPC api over HTTP since the error is in the payload.

❯ curl --request POST \
  --url \
  --header 'Authorization: Basic ***' \
  --header 'Content-Type: application/json' \
  --data '{
        "jsonrpc": "2.0",
        "method": "Filecoin.StateListMiners",
        "params": [],
        "id": 3
{"jsonrpc":"2.0","id":3,"error":{"code":-32602,"message":"wrong param count (method 'Filecoin.StateListMiners'): 0 != 1"}}
1 Like

Great stuff! Thanks for the quick turnaround :slight_smile: