{"record":{"id":"a93e9b5760f823bf","repo":"SeleniumHQ/selenium","slug":"expected-http-proxy-got-proxy-inspect","errorCode":null,"errorMessage":"expected HTTP proxy, got #{proxy.inspect}","messagePattern":"expected HTTP proxy, got #(.+?)","errorType":"exception","errorClass":"Error::WebDriverError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/http/default.rb","lineNumber":151,"sourceCode":"          def new_request_for(verb, url, headers, payload)\n            req = Net::HTTP.const_get(verb.to_s.capitalize).new(url.path, headers)\n\n            req.basic_auth server_url.user, server_url.password if server_url.userinfo\n\n            req.body = payload if payload\n\n            req\n          end\n\n          def response_for(request)\n            http.request request\n          end\n\n          def new_http_client\n            if use_proxy?\n              url = proxy.http\n              unless proxy.respond_to?(:http) && url\n                raise Error::WebDriverError,\n                      \"expected HTTP proxy, got #{proxy.inspect}\"\n              end\n\n              proxy_uri = URI.parse(url)\n\n              Net::HTTP.new(server_url.host, server_url.port,\n                            proxy_uri.host, proxy_uri.port, proxy_uri.user, proxy_uri.password)\n            else\n              Net::HTTP.new server_url.host, server_url.port\n            end\n          end\n\n          def proxy\n            client_config.proxy\n          end\n\n          def use_proxy?\n            return false if proxy.nil?","sourceCodeStart":133,"sourceCodeEnd":169,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/http/default.rb#L133-L169","documentation":"Raised as Error::WebDriverError by Http::Default#new_http_client when a proxy is configured for use (use_proxy? is true) but the proxy object does not respond to #http or its #http method returns a falsy value. The adapter needs a valid proxy URL string to construct the Net::HTTP proxy connection; without it, it cannot route traffic through the proxy.","triggerScenarios":"Setting a proxy via the HTTP client that is not a valid Selenium::WebDriver::Proxy with an :http or :ssl entry. Passing a custom proxy object missing the #http method. Configuring proxy= with a Proxy whose http and ssl are both nil. Passing a string URL to proxy= (the setter may accept it but #http won't resolve).","commonSituations":"Configuring an HTTP transport-level proxy (distinct from browser-level proxy capabilities) incorrectly. Passing a SOCKS proxy specification when only HTTP proxy is supported. Partial proxy config (setting only :ftp or :ssl in a way that leaves :http nil). Version changes to the Proxy API.","solutions":["Ensure the proxy object responds to #http and returns a valid URL string: Selenium::WebDriver::Proxy.new(http: 'host:8080', ssl: 'host:8080').","If using a custom proxy object, implement #http returning a non-nil URL string.","Verify both :http and :ssl proxy entries are set when the remote endpoint uses HTTPS.","If you don't actually need an HTTP-client-level proxy, clear it rather than leaving a partial/broken proxy config."],"exampleFix":"# before\nclient.proxy = Selenium::WebDriver::Proxy.new(ssl: 'proxyhost:8080')  # :http is nil\n\n# after\nclient.proxy = Selenium::WebDriver::Proxy.new(http: 'proxyhost:8080', ssl: 'proxyhost:8080')","handlingStrategy":"type-guard","validationCode":"# Validate the proxy object before assignment:\nif use_proxy && !(proxy.respond_to?(:http) && proxy.http)\n  raise ArgumentError, 'proxy must respond to #http with a non-nil URL'\nend","typeGuard":"def valid_http_proxy?(proxy)\n  proxy.respond_to?(:http) && !proxy.http.nil?\nend","tryCatchPattern":"begin\n  client.request(verb, url)\nrescue Selenium::WebDriver::Error::WebDriverError => e\n  raise unless e.message.include?('expected HTTP proxy')\n  raise 'Configure proxy with both :http and :ssl entries'\nend","preventionTips":["Always set both :http and :ssl on Proxy objects for HTTP-client-level proxying.","Verify the proxy object responds to #http with a non-nil URL string.","Test proxy connectivity independently before using it with WebDriver."],"tags":["http-client","proxy","config-mistake","network"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}