Skip to content

Thunder Extension crashes when receiving errors #267

@adamdama

Description

@adamdama

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions