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

RoundTripper returns a non-nil response and error #179

Open
bmendric opened this issue Jan 23, 2023 · 0 comments
Open

RoundTripper returns a non-nil response and error #179

bmendric opened this issue Jan 23, 2023 · 0 comments

Comments

@bmendric
Copy link

bmendric commented Jan 23, 2023

The code in question here is within RoundTripper.RoundTrip() which, in the check for url.Error, returns both the response and an error.

https://github.com/hashicorp/go-retryablehttp/blob/master/roundtripper.go#L47

While this behavior is not explicitly disallowed by the interface, the net/http.Client implementation does check for this and will print a corresponding log error. This erroneous log message is particularly annoying when expecting all program output to be JSON, which is how I found this.

From this conversation, that validation is expected.

EDIT: Also of note, this is eluded to in the docs of the net/http.RoundTripper interface with the line "A non-nil err should be reserved for failure to obtain a response", but it could certainly be worded better/more explicitly on that side.

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

No branches or pull requests

1 participant