Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not detecting errors from server #44

Open
poplexity opened this issue Oct 21, 2024 · 0 comments
Open

Not detecting errors from server #44

poplexity opened this issue Oct 21, 2024 · 0 comments

Comments

@poplexity
Copy link
Member

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:

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant