toland / patron

Ruby HTTP client based on libcurl
http://toland.github.com/patron/
MIT License
541 stars 74 forks source link

VCR issues after upgrading patron 0.10.0 -> 0.11.1 #157

Closed henrik closed 6 years ago

henrik commented 6 years ago

After upgrading patron, I got errors in some VCR tests like:

  1) My test
     Failure/Error: client.reset_organization

     NoMethodError:
       undefined method `[]' for nil:NilClass
     # ./tmp/devbox/gems/gems/patron-0.11.1/lib/patron/response.rb:120:in `parse_headers'
     # ./tmp/devbox/gems/gems/patron-0.11.1/lib/patron/response.rb:44:in `initialize'
     # ./tmp/devbox/gems/gems/webmock-3.3.0/lib/webmock/http_lib_adapters/patron_adapter.rb:108:in `new'

Downgrading fixed them.

I'm on VCR 4.0.0.

julik commented 6 years ago

Thank you for reporting! I am almost certain this is related to the new header parsing code we introduced. The line you are referring to does this:

responses = Patron::HeaderParser.parse(header_data_for_multiple_responses)
last_response = responses[-1] # Only use the last response (for proxies and redirects)

It is a bit hard for me to imagine how the responses can be nil in this case, and I doubt I can reproduce this myself without your help. Can you set up a smaller app that demonstrates the problem? If you don't feel like sharing your cassette that causes it on GH you can pass it directly to me off-band and I will see to it that we rectify it into a test case.

julik commented 6 years ago

@henrik ?

henrik commented 6 years ago

Hi @julik! Sorry about the delay in replying. Thank you, that makes sense. I emailed you a cassette in case that helps – I'm rather limited for time right now, but I've made a note of this ticket in our codebase and will write again if we come back to this code and make a repro or a PR.

julik commented 6 years ago

Thanks, I'll play with it and get back to you.

julik commented 6 years ago

Thanks! I nailed the issue to Webmock doing things to the headers string it should not be doing.

henrik commented 6 years ago

Oh, brilliant! Good job on figuring it out.