diff --git a/CHANGELOG_PENDING.md b/CHANGELOG_PENDING.md index a07d2a79c..0f688ff82 100644 --- a/CHANGELOG_PENDING.md +++ b/CHANGELOG_PENDING.md @@ -71,7 +71,7 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi - [rpc/client/http] \#6163 Do not drop events even if the `out` channel is full (@melekes) - [node] \#6059 Validate and complete genesis doc before saving to state store (@silasdavis) - [state] \#6067 Batch save state data (@githubsands & @cmwaters) -- [privval/file] \#6185 Return error on `LoadFilePV`, `LoadFilePVEmptyState`. Allows for better programmatic control of Tendermint. +- [privval/file] \#6185 Return error on `LoadFilePV`, `LoadFilePVEmptyState`. Allows for better programmatic control of Tendermint. ### BUG FIXES @@ -79,3 +79,4 @@ Friendly reminder: We have a [bug bounty program](https://hackerone.com/tendermi - [privval] \#5638 Increase read/write timeout to 5s and calculate ping interval based on it (@JoeKash) - [blockchain/v1] [\#5701](https://github.com/tendermint/tendermint/pull/5701) Handle peers without blocks (@melekes) - [blockchain/v1] \#5711 Fix deadlock (@melekes) +- [rpc/jsonrpc/server] \#6191 Correctly unmarshal `RPCRequest` when data is `null` (@melekes) diff --git a/rpc/jsonrpc/types/types.go b/rpc/jsonrpc/types/types.go index 3ed2b375d..4435c8c5d 100644 --- a/rpc/jsonrpc/types/types.go +++ b/rpc/jsonrpc/types/types.go @@ -57,27 +57,31 @@ type RPCRequest struct { // UnmarshalJSON custom JSON unmarshaling due to jsonrpcid being string or int func (req *RPCRequest) UnmarshalJSON(data []byte) error { - unsafeReq := &struct { + unsafeReq := struct { JSONRPC string `json:"jsonrpc"` ID interface{} `json:"id,omitempty"` Method string `json:"method"` Params json.RawMessage `json:"params"` // must be map[string]interface{} or []interface{} }{} + err := json.Unmarshal(data, &unsafeReq) if err != nil { return err } + + if unsafeReq.ID == nil { // notification + return nil + } + req.JSONRPC = unsafeReq.JSONRPC req.Method = unsafeReq.Method req.Params = unsafeReq.Params - if unsafeReq.ID == nil { - return nil - } id, err := idFromInterface(unsafeReq.ID) if err != nil { return err } req.ID = id + return nil }