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

Fix deserialization of messages with null IDs #465

Merged
merged 1 commit into from
May 18, 2020

Conversation

AArnott
Copy link
Member

@AArnott AArnott commented May 17, 2020

JSON-RPC allows null as a request id value (bizarrely enough). And while we might not care to support interop with folks who use null as a value, it can legitimately come in response to a request where the server failed to parse in our request. I can't imagine a situation where that would happen, but there are pretty strange JSON-RPC servers out there, and I've heard from one user of this library that this came up.

The goal of this change is to update the code to acknowledge the validity of the null value at the schema level so that instead of a rather bizarre error when the situation is encountered, the oddity gets further in our pipeline where a more helpful error can be produced.

I add several tests including mocked up interop tests to demonstrate the intended behavior.

@AArnott AArnott added this to the v2.5 milestone May 17, 2020
@AArnott AArnott self-assigned this May 17, 2020
@codecov-io
Copy link

codecov-io commented May 18, 2020

Codecov Report

Merging #465 into master will decrease coverage by 0.22%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #465      +/-   ##
==========================================
- Coverage   90.59%   90.37%   -0.23%     
==========================================
  Files          50       50              
  Lines        3797     3812      +15     
==========================================
+ Hits         3440     3445       +5     
- Misses        357      367      +10     
Impacted Files Coverage Δ
...mJsonRpc/EventArgs/JsonRpcDisconnectedEventArgs.cs 57.14% <100.00%> (-31.10%) ⬇️
src/StreamJsonRpc/JsonRpc.cs 92.98% <100.00%> (+0.03%) ⬆️
src/StreamJsonRpc/MessagePackFormatter.cs 93.40% <100.00%> (-0.52%) ⬇️
src/StreamJsonRpc/RequestId.cs 73.07% <100.00%> (+4.89%) ⬆️
src/StreamJsonRpc/RequestIdJsonConverter.cs 90.00% <100.00%> (+1.11%) ⬆️
src/StreamJsonRpc/Resources.Designer.cs 69.44% <100.00%> (+0.43%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2310ff1...f89ff0b. Read the comment docs.

@AArnott AArnott force-pushed the HandleNullRequestId branch from 5a8128c to 3ab1143 Compare May 18, 2020 03:05
@AArnott AArnott force-pushed the HandleNullRequestId branch from 3ab1143 to f89ff0b Compare May 18, 2020 03:07
@AArnott AArnott merged commit ef2a5d8 into microsoft:master May 18, 2020
@AArnott AArnott deleted the HandleNullRequestId branch May 18, 2020 03:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants