attestantio / go-eth2-client

Apache License 2.0
102 stars 59 forks source link

Malformed JSON logs #143

Closed adaszko closed 1 month ago

adaszko commented 1 month ago

Hi,

I'm doing cat vouch.log | while read line; do echo $line; echo $line | jq .message; done and am routinely getting errors from jq like parse error: Invalid numeric literal at line 1, column 225. The errors are actually misleading since it's not about numeric literals at all. The problem is log entries "POST request" often don't have properly escaped "body". I believe this line is to blame: https://github.com/attestantio/go-eth2-client/blob/23b592ca8bd919404d8ebe4860a60939c4ae53a3/http/http.go#L50 as it doesn't escape " or any other special characters. I think piping it through json.Marshal(...) would do the trick.

Thanks!

mcdee commented 1 month ago

Thanks for reporting this; a fix has been added and so this issue will be addressed in the next release.

adaszko commented 1 month ago

Lovely, thank you!