-
Notifications
You must be signed in to change notification settings - Fork 15
Thunder Extension crashes when receiving errors #267
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
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:
- Handle JSON-RPC errors. Error responses form part of the JSON-RPC spec and we should be handling them properly.
- 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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working