You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/// This function processes response from query method to introduce
/// backward compatible response in case of specific errors
fnprocess_query_response(
The implication of this, is that, instead of the server returning structured errors in the VErr format (#2976), it returns a custom JSON response with the error contained inside a string. And worse of all, under the guise of a "result" instead of an "error".
// $ http ... method=query params='{"request_type":"view_access_key","account_id":"test.near","public_key":"..."}'{"jsonrpc": "2.0","result": {// <-- returns "result" instead of "error""block_hash": "HZUfyFnKD8uneRDc8LYWe2xxMWFBYj2oxes3iZuwYAPX","block_height": 84145708,"error": "access key ed25519:J9rU3yZhwZB3UriwvETEcuf1a7FyS3sz5sTsmH2z8zTe does not exist while viewing","logs": []},"id": "dontcare"}
Expected behavior
I personally feel we should migrate totally off unstructured server responses and have something to the effect of:
// $ http ... method=query params='{"request_type":"view_access_key","account_id":"test.near","public_key":"..."}'{"jsonrpc": "2.0","error": {"name": "HANDLER_ERROR","cause": {"info": {"public_key": "ed25519:J9rU3yZhwZB3UriwvETEcuf1a7FyS3sz5sTsmH2z8zTe","block_height": 84145708,"block_hash": "HZUfyFnKD8uneRDc8LYWe2xxMWFBYj2oxes3iZuwYAPX"},"name": "UNKNOWN_ACCESS_KEY"},"code": -32000,"message": "Server error","data": "access key ed25519:J9rU3yZhwZB3UriwvETEcuf1a7FyS3sz5sTsmH2z8zTe does not exist while viewing"},"id": "dontcare"}
Additional context
The extended impact of this, is, on near-jsonrpc-client, when deserializing the server response back into the RpcQueryError structure, it fails from attempting to parse the unstructured data the server responds with.
Describe the bug
Following #3944, the
process_query_response
method was introduced to maintain backwards compatibility when reporting some variants ofQueryError
.nearcore/chain/jsonrpc/src/lib.rs
Lines 129 to 131 in 78c4b0c
The implication of this, is that, instead of the server returning structured errors in the
VErr
format (#2976), it returns a custom JSON response with the error contained inside a string. And worse of all, under the guise of a"result"
instead of an"error"
.Expected behavior
I personally feel we should migrate totally off unstructured server responses and have something to the effect of:
Additional context
The extended impact of this, is, on
near-jsonrpc-client
, when deserializing the server response back into theRpcQueryError
structure, it fails from attempting to parse the unstructured data the server responds with.cc: @frol @khorolets
The text was updated successfully, but these errors were encountered: