Skip to content

Commit

Permalink
Fix Error response prior to being able to parse the Request.ID
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSLevy committed Dec 3, 2018
1 parent eaf463d commit 9e5841f
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,13 @@ func processRequest(methods MethodMap, rawReq json.RawMessage) Response {
var req safeRequest
if err := unmarshalStrict(rawReq, &req); err != nil ||
!req.IsValid() {
return newErrorResponse(nil, InvalidRequest)
// Since the request was not valid for some reason, we cannot
// assume anything about the ID or whether it was a
// Notification or not. Thus we must return an Error Response.
// In order to ensure the handler doesn't omit the Response by
// confusing it with a Notification, we must populate the ID
// field with the JSON null value.
return newErrorResponse(json.RawMessage("null"), InvalidRequest)
}
// Clear null params before calling the method.
if string(req.Params) == "null" {
Expand Down

0 comments on commit 9e5841f

Please sign in to comment.