You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In one of our projects we are checking old links, and one of them throws a NoMethodError when using the FollowRedirects middleware. This happens because the Location: is malformed and the site tries to redirect to "http://". This causes the following NoMethodError:
NoMethodError: undefined method `+' for nil:NilClass
from /usr/lib64/ruby/2.3.0/net/http.rb:1561:in `addr_port'
from /usr/lib64/ruby/2.3.0/net/http.rb:1494:in `begin_transport'
from /usr/lib64/ruby/2.3.0/net/http.rb:1433:in `transport_request'
from /usr/lib64/ruby/2.3.0/net/http.rb:1407:in `request'
from /usr/lib64/ruby/2.3.0/net/http.rb:1400:in `block in request'
from /usr/lib64/ruby/2.3.0/net/http.rb:853:in `start'
from /usr/lib64/ruby/2.3.0/net/http.rb:1398:in `request'
from /usr/lib64/ruby/2.3.0/net/http.rb:1156:in `get'
from /usr/lib64/ruby/gems/2.3.0/gems/faraday-0.11.0/lib/faraday/adapter/net_http.rb:78:in `perform_request'
from /usr/lib64/ruby/gems/2.3.0/gems/faraday-0.11.0/lib/faraday/adapter/net_http.rb:38:in `block in call'
from /usr/lib64/ruby/gems/2.3.0/gems/faraday-0.11.0/lib/faraday/adapter/net_http.rb:85:in `with_net_http_connection'
from /usr/lib64/ruby/gems/2.3.0/gems/faraday-0.11.0/lib/faraday/adapter/net_http.rb:33:in `call'
from /usr/lib64/ruby/gems/2.3.0/gems/faraday_middleware-0.11.0/lib/faraday_middleware/gzip.rb:24:in `call'
from /usr/lib64/ruby/gems/2.3.0/gems/faraday_middleware-0.11.0/lib/faraday_middleware/response/follow_redirects.rb:78:in `perform_with_redirection'
I could catch the NoMethodError in my calling method to catch this, but I'm a bit wary to catch a generic error here. Perhaps the FollowRedirect module should validate that the redirected location is a valid URL before redirecting?
The text was updated successfully, but these errors were encountered:
Thanks @graaff, that looks like a great use-case for a unit test!
And since this is relatively easy, I've marked it as a good first issue for anyone who would like to help out 😄
In one of our projects we are checking old links, and one of them throws a NoMethodError when using the FollowRedirects middleware. This happens because the Location: is malformed and the site tries to redirect to "http://". This causes the following NoMethodError:
I could catch the NoMethodError in my calling method to catch this, but I'm a bit wary to catch a generic error here. Perhaps the FollowRedirect module should validate that the redirected location is a valid URL before redirecting?
The text was updated successfully, but these errors were encountered: