Skip to content

Exception: NoMethodError: undefined method `include?' for nil - in lib/net/http.rb:2466Β #184

@rgaufman

Description

@rgaufman

I'm getting:

Exception: NoMethodError: undefined method `include?' for nil

Here:

vendor/bundle/ruby/3.3.0/gems/net-http-0.4.1/lib/net/http.rb:2466:in `addr_port'
vendor/bundle/ruby/3.3.0/gems/net-http-0.4.1/lib/net/http.rb:2401:in `begin_transport'
vendor/bundle/ruby/3.3.0/gems/net-http-0.4.1/lib/net/http.rb:2332:in `transport_request'
vendor/bundle/ruby/3.3.0/gems/net-http-0.4.1/lib/net/http.rb:2306:in `request'
vendor/bundle/ruby/3.3.0/gems/airbrake-13.0.4/lib/airbrake/rails/net_http.rb:11:in `block in request'
vendor/bundle/ruby/3.3.0/gems/airbrake-13.0.4/lib/airbrake/rack.rb:21:in `capture_timing'
vendor/bundle/ruby/3.3.0/gems/airbrake-13.0.4/lib/airbrake/rails/net_http.rb:10:in `request'
vendor/bundle/ruby/3.3.0/gems/faraday-net_http-3.3.0/lib/faraday/adapter/net_http.rb:112:in `block in request_with_wrapped_block'
vendor/bundle/ruby/3.3.0/gems/net-http-0.4.1/lib/net/http.rb:1570:in `start'
vendor/bundle/ruby/3.3.0/gems/faraday-net_http-3.3.0/lib/faraday/adapter/net_http.rb:111:in `request_with_wrapped_block'
vendor/bundle/ruby/3.3.0/gems/faraday-net_http-3.3.0/lib/faraday/adapter/net_http.rb:101:in `perform_request'
vendor/bundle/ruby/3.3.0/gems/faraday-net_http-3.3.0/lib/faraday/adapter/net_http.rb:65:in `block in call'
vendor/bundle/ruby/3.3.0/gems/faraday-2.11.0/lib/faraday/adapter.rb:45:in `connection'
vendor/bundle/ruby/3.3.0/gems/faraday-net_http-3.3.0/lib/faraday/adapter/net_http.rb:64:in `call'
vendor/bundle/ruby/3.3.0/gems/faraday-2.11.0/lib/faraday/middleware.rb:56:in `call'
vendor/bundle/ruby/3.3.0/gems/faraday-2.11.0/lib/faraday/rack_builder.rb:152:in `build_response'
vendor/bundle/ruby/3.3.0/gems/faraday-2.11.0/lib/faraday/connection.rb:452:in `run_request'
vendor/bundle/ruby/3.3.0/gems/faraday-2.11.0/lib/faraday/connection.rb:200:in `get'

This is the code responsible:

    def addr_port
      addr = address
      addr = "[#{addr}]" if addr.include?(":") # the .include? here
      default_port = use_ssl? ? HTTP.https_default_port : HTTP.http_default_port
      default_port == port ? addr : "#{addr}:#{port}"
    end

It seems there should be some kind of validation earlier to avoid this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions