Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Debug emits incorrect body when body contains % #270

Closed
kmanley opened this issue Sep 10, 2019 · 5 comments
Closed

Debug emits incorrect body when body contains % #270

kmanley opened this issue Sep 10, 2019 · 5 comments
Assignees
Labels

Comments

@kmanley
Copy link

kmanley commented Sep 10, 2019

If the request body contains a % (e.g. because it has urlencoded form data) then the debug logger attempts to interpret the body as a format string with no params, because it uses Logger.Debugf which uses Printf. This causes the output to show printf errors.

You end up with something malformed in the debug output like this

DEBUG RESTY
==================
~~~ REQUEST ~~~
POST  /v1/users  HTTP/1.1
HOST   : s1apiv2.rapidfunnel.com
HEADERS:
                   Accept: application/json
            Authorization: esdfjalyJhbGciOiJIUzUxMiIsInR5cCI6IkpXVCJ9.eyJkYXRhIjoiMjk3YTEzZDlhZDdiYTEwZDVjMDliZjA5MmExm5lbC5jb20iLCJuYmYiOjE1NjgxNDk3MzB9.o9DkPzn5M5lMf8D1M8RP5yGSagjfhEg68GRFeq0Dl_sK_kPf-dyhn4-AOeYZYd8sDTf22VL8TAmXYV-WIBF3Fw
             Content-Type: application/x-www-form-urlencoded
               User-Agent: go-resty/2.1.0 (https://github.com/go-resty/resty)
BODY   :
email=foo%!B(MISSING)test%!(MISSING)foo.com&firstName=Joe&lastName=Test&password=password

This is bad because the whole point of the debug output is to show what is going out on the wire, and this does not correctly represent what's going on the wire.

I will submit a PR

kmanley pushed a commit to kmanley/resty that referenced this issue Sep 10, 2019
@jeevatkm
Copy link
Member

@kmanley Thank you for reporting an issue and PR too 😄

BTW, v2.1.0 is not released yet. Are you using Resty library directly without any package management tool (go mod, etc.)?

@kmanley
Copy link
Author

kmanley commented Sep 11, 2019

Hi @jeevatkm yes I am using latest resty via go get.

@jeevatkm
Copy link
Member

@kmanley Okay, thanks I have merged your PR into master.

@kmanley
Copy link
Author

kmanley commented Sep 11, 2019

Great - thanks for making resty it has saved me a lot of time 👍

@jeevatkm
Copy link
Member

Thank you @kmanley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

2 participants