diff --git a/CHANGELOG.md b/CHANGELOG.md index 53748f3cf6..01c14428b9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ ### Chore - [#2590](https://github.com/poanetwork/blockscout/pull/2590) - restore backward compatablity with old releases +- [#2574](https://github.com/poanetwork/blockscout/pull/2574) - limit request body in json rpc error - [#2566](https://github.com/poanetwork/blockscout/pull/2566) - upgrade absinthe phoenix diff --git a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/decode_error.ex b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/decode_error.ex index 1b77eac048..5b2fea35cc 100644 --- a/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/decode_error.ex +++ b/apps/ethereum_jsonrpc/lib/ethereum_jsonrpc/decode_error.ex @@ -35,11 +35,23 @@ defmodule EthereumJSONRPC.DecodeError do %EthereumJSONRPC.DecodeError{request: request, response: response} end + @request_body_limit 700 + @impl Exception def message(%EthereumJSONRPC.DecodeError{ request: %EthereumJSONRPC.DecodeError.Request{url: request_url, body: request_body}, response: %EthereumJSONRPC.DecodeError.Response{status_code: response_status_code, body: response_body} }) do + request_body_binary = IO.iodata_to_binary(request_body) + + truncated_request_body = + if byte_size(request_body_binary) < @request_body_limit do + request_body_binary + else + <> = request_body_binary + result + end + """ Failed to decode Ethereum JSONRPC response: @@ -47,7 +59,7 @@ defmodule EthereumJSONRPC.DecodeError do url: #{request_url} - body: #{IO.iodata_to_binary(request_body)} + body: #{truncated_request_body} response: