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

Thunder Extension crashes when receiving errors #267

Open
adamdama opened this issue Oct 6, 2023 · 0 comments
Open

Thunder Extension crashes when receiving errors #267

adamdama opened this issue Oct 6, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@adamdama
Copy link
Contributor

adamdama commented Oct 6, 2023

In the thunder_ripple_sdk there are a few places where a response from Thunder is assumed to be of a certain shape. This assumption is relied on to parse and deserialize the data in the response from Thunder. This means that if the response is not the expected one there is a panic which crashes the Thunder extension.

For example in device/thunder_ripple_sdk/src/processors/thunder_device_info.rs:

                let resp = state
                    .get_thunder_client()
                    .call(DeviceCallRequest {
                        method: ThunderPlugin::System.method("getSystemVersions"),
                        params: None,
                    })
                    .await;
                // FIXME: if the thunder plugin does not respond then we panic on the unwrap here. This would be a problem if the Thunder System plugin was not loaded
                info!("{}", resp.message);
                let tsv: SystemVersion = serde_json::from_value(resp.message).unwrap();

The unwrap on the last line of the example is the problem. There are two cases that we need to account for when receiving messages from Thunder:

  1. Handle JSON-RPC errors. Error responses form part of the JSON-RPC spec and we should be handling them properly.
  2. Responses which do not conform to the expected shape For example, if a Thunder plugin adds fields or removes fields from a JSON-RPC response we should be able to handle it more gracefully.
@adamdama adamdama added the bug Something isn't working label Oct 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant