forest icon indicating copy to clipboard operation
forest copied to clipboard

Improve `INTERNAL_ERROR` in JSON-RPC server

Open elmattic opened this issue 1 year ago • 2 comments

          `INTERNAL_ERROR` is suitable for e.g handler panic - treat it like HTTP `500 Internal Server Error `.

Use other error codes (outside of the -32000..=-32099 range), here.

OTOH, if lotus always just always returns INTERNAL_ERROR, we might decide to copy that. After this discussion, I'll leave this up to your judgement

Originally posted by @aatifsyed in https://github.com/ChainSafe/forest/pull/3943#discussion_r1494469217

elmattic avatar Feb 19 '24 14:02 elmattic

Adding a link to the specification: https://www.jsonrpc.org/specification#error_object

elmattic avatar Feb 19 '24 14:02 elmattic

Lotus doesn't always return INTERNAL_ERROR e.g

In [15]: client["Filecoin.ChainGetTipSet"]([])
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
Cell In[15], line 1
----> 1 client["Filecoin.ChainGetTipSet"]([])

File ~/chainsafe/forest/test.py:89, in _Method.__call__(self, *args)
     87 error = json_rpc_response.pop("error", None)
     88 if error is not None:
---> 89     raise RuntimeError(error)
     91 return json_rpc_response["result"]

RuntimeError: {'code': 1, 'message': 'NewTipSet called with zero length array of blocks'}

aatifsyed avatar Feb 19 '24 17:02 aatifsyed

This is not actionable, as we have to follow Lotus' lead. Closing.

lemmih avatar Aug 02 '24 13:08 lemmih