Skip to content

No way to respond to malformed message #196

@ljw1004

Description

@ljw1004

Suppose the server receives an invalid json {"foo": "bar"} which lacks jsonrpc and method and id.

(Per the spec this isn't a Message because it lacks the required field jsonrpc, and its not a RequestMessage because it lacks the field id, and it's not even a Notification because it lacks the field method).

I'd ideally like it to respond back with this ResponseMessage:

{
  "jsonrpc":"2.0",
  "error": { "code":-32700, "message":"parse error" }
}

However this response isn't allowed per the spec. That's because the spec only defines responses for when it has a valid id. It doesn't even allow responses for notifications (which lack id).

What can we do? I think the spec should change its definition of ResponseMessage to allow id field to be either ABSENT or NULL in the case where it wants to report an error back to the client but wasn't given an id. (I'm not sure whether absent or null would be more idiomatic json).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions