Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Exception because a request object has an invalid id #109

Copy link
Copy link

Description

@pedrolcl
Issue body actions

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

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Morty Proxy This is a proxified and sanitized view of the page, visit original site.