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).
Suppose the server receives an invalid json
{"foo": "bar"}which lacksjsonrpcandmethodandid.(Per the spec this isn't a Message because it lacks the required field
jsonrpc, and its not a RequestMessage because it lacks the fieldid, and it's not even a Notification because it lacks the fieldmethod).I'd ideally like it to respond back with this ResponseMessage:
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 lackid).What can we do? I think the spec should change its definition of ResponseMessage to allow
idfield 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).