Reorder variants of Incoming message enum to force incoming client responses to be parsed properly as Incoming::Response.
It seems that client request support has been broken since 0.13.3 due to an overlap in deserialization of incoming client responses, causing them to be incorrectly identified by serde as server RequestKind::Invalid instead of ClientMethod::Response.
This occurred due to the variant ordering of the Incoming enum, where the Incoming::Request branch would always be attempted before Incoming::Response. This meant that the overly permissive catch-all "invalid server request" case would swallow up the incoming client response and the Incoming::Response branch would never be attempted.
By simply swapping the order of the enum variants, we can ensure that the incoming deserialization order is fixed as follows:
Incoming client response
Incoming server request (valid)
Incoming server request (invalid, fall-through case)
To prevent such a bug from occurring again, this commit extends and hardens the jsonrpc.rs unit test suite to check that both Incoming and Outgoing parse JSON-RPC requests and responses correctly and verify that the correct enum variants are chosen as a result.
Fixes #267.
Closes #244, which previously attempted to fix this issue but broke JSON-RPC status code correctness along the way.
Fixed
Incoming
message enum to force incoming client responses to be parsed properly asIncoming::Response
.It seems that client request support has been broken since 0.13.3 due to an overlap in deserialization of incoming client responses, causing them to be incorrectly identified by
serde
as serverRequestKind::Invalid
instead ofClientMethod::Response
.This occurred due to the variant ordering of the
Incoming
enum, where theIncoming::Request
branch would always be attempted beforeIncoming::Response
. This meant that the overly permissive catch-all "invalid server request" case would swallow up the incoming client response and theIncoming::Response
branch would never be attempted.By simply swapping the order of the enum variants, we can ensure that the incoming deserialization order is fixed as follows:
To prevent such a bug from occurring again, this commit extends and hardens the
jsonrpc.rs
unit test suite to check that bothIncoming
andOutgoing
parse JSON-RPC requests and responses correctly and verify that the correct enum variants are chosen as a result.Fixes #267. Closes #244, which previously attempted to fix this issue but broke JSON-RPC status code correctness along the way.