go-resty / resty

Simple HTTP and REST client library for Go
MIT License
10.01k stars 706 forks source link

fix: 'invalid memory address or nil pointer dereference' in response logger #872

Closed matlockx closed 2 weeks ago

matlockx commented 2 weeks ago

An error like ‘dial tcp 10.66.0.229:80: connect: connection refused’ when request and response logging is activated causes an ‘invalid memory address or nil pointer dereference’. This is due to changes from version 2.14 to 2.15, where the logging call was moved up in the execute function. In version 2.14, the function returned early on this error, so the logging call was not made. Now, the logging call is made, and res.RawResponseProto is used without a nil check on RawResponse.

The fix is simple: use res.Proto(), which performs the nil check.

fixes #873

codecov[bot] commented 2 weeks ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 96.15%. Comparing base (231ca0e) to head (b71c78a). Report is 1 commits behind head on v2.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## v2 #872 +/- ## ======================================= Coverage 96.15% 96.15% ======================================= Files 14 14 Lines 1821 1821 ======================================= Hits 1751 1751 Misses 46 46 Partials 24 24 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

jeevatkm commented 2 weeks ago

@matlockx I was able to make the release prep work on the browser. Now, v2.15.3 has been released.