-
Notifications
You must be signed in to change notification settings - Fork 1
Description
For example when fetching table rows, if you pass a bad value for scope (a bug with Name type that was fixed already caused this example), then the server has an error. This error does not get picked up in match against result here:
antelope-rs/crates/antelope/src/api/v1/chain.rs
Lines 244 to 247 in ccd4422
let response = match result.await { | |
Ok(response) => response, | |
Err(_) => return Err(ClientError::NETWORK("Failed to get table rows".into())), | |
}; |
So, it continues beyond that and then attempts to parse the JSON and extract table row response values from an error payload:
"{"code":500,"message":"Internal Service Error","error":{"code":3010000,"name":"chain_type_exception","what":"chain type exception","details":[{"message":"Could not convert scope string '.' to any of the following: uint64_t, valid name, or valid symbol (with or without the precision)","file":"chain_plugin.cpp","line_number":1483,"method":"convert_to_type"}]}}"
Which fails here:
let more = response_obj.get_bool("more")?; |
Because more
is None
and so the error seems like a bad response but really the issue is that we aren't properly check the response to be an error.
The match above likely checks for http level failures, and in this case it's a healthy http response that contains an error payload. Need to figure out the right fields in an http response to check to see if the response is an error before we continue to treat it as a healthy response payload. HINT: Check how the antelope typescript library does it in WharfKit