-
Notifications
You must be signed in to change notification settings - Fork 87
Closed
Description
Consider this new test case. It contains a request with an object as the id attribute. This is against the 2.0 specification:
[Test()]
public void TestWrongIdType()
{
string request = @"{method:'TestOptionalParamdouble',params:{input:5},id:{what:4,that:3}}";
var result = JsonRpcProcessor.Process(request);
result.Wait();
Assert.IsTrue(result.Result.Contains("error"));
}
It fails throwing an ugly exception because the 'id' attribute is an object instead of a simple value.
The right solution should be to complain about the malformed request returning a -32600 code, and refuse to process the request altogether, instead of failing when serializing the response. Another option, unorthodox but easy to fix, would be to allow objects in the id attribute.
Complete stack trace:
Newtonsoft.Json.JsonWriterException
HResult=0x80131500
Message=Unsupported type: Newtonsoft.Json.Linq.JObject. Use the JsonSerializer class to get the object's JSON representation. Path ''.
Source=Newtonsoft.Json
StackTrace:
at Newtonsoft.Json.JsonWriter.WriteValue(JsonWriter writer, PrimitiveTypeCode typeCode, Object value)
at Newtonsoft.Json.JsonWriter.WriteValue(Object value)
at Newtonsoft.Json.JsonTextWriter.WriteValue(Object value)
at AustinHarris.JsonRpc.JsonRpcProcessor.ProcessInternal(String sessionId, String jsonRpc, Object jsonRpcContext) in C:\Users\plopezc\source\repos\JsonRpcNet\Json-Rpc\JsonRpcProcessor.cs:line 135
at AustinHarris.JsonRpc.JsonRpcProcessor.<>c.<Process>b__3_0(Object _) in C:\Users\plopezc\source\repos\JsonRpcNet\Json-Rpc\JsonRpcProcessor.cs:line 39
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels