SeleniumHQ/selenium · error · ArgumentError

unknown option#{'s' if not_allowed.size != 1}: #{not_allowed

Error message

unknown option#{'s' if not_allowed.size != 1}: #{not_allowed.inspect}

What it means

Proxy.new iterates the options hash and only accepts keys present in the ALLOWED map (:type, :http, :no_proxy, :pac, :ssl, :auto_detect, :socks, :socks_username, :socks_password, :socks_version). Any unrecognized key is collected and, if any exist, ArgumentError is raised listing them. The message pluralizes to 'options' when more than one is rejected.

Source

Thrown at rb/lib/selenium/webdriver/common/proxy.rb:70

        end

        proxy
      end

      def initialize(opts = {})
        not_allowed = []

        opts.each do |k, v|
          if ALLOWED.key?(k)
            send(:"#{k}=", v)
          else
            not_allowed << k
          end
        end

        return if not_allowed.empty?

        raise ArgumentError, "unknown option#{'s' if not_allowed.size != 1}: #{not_allowed.inspect}"
      end

      def ==(other)
        other.is_a?(self.class) && as_json == other.as_json
      end
      alias eql? ==

      def http=(value)
        self.type = :manual
        @http = value
      end

      def no_proxy=(value)
        self.type = :manual
        @no_proxy = value
      end

      def ssl=(value)

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Use only ALLOWED keys: :type, :http, :no_proxy, :pac, :ssl, :auto_detect, :socks, :socks_username, :socks_password, :socks_version.
  2. Remove unrelated keys from the hash before passing it to Proxy.new.
  3. Inspect Selenium::WebDriver::Proxy::ALLOWED to confirm valid key names.

Example fix

# before
proxy = Selenium::WebDriver::Proxy.new(ftp: 'proxy.example.com:8080')

# after
proxy = Selenium::WebDriver::Proxy.new(http: 'proxy.example.com:8080')
Defensive patterns

Strategy: validation

Validate before calling

allowed = Selenium::WebDriver::Proxy::ALLOWED.keys
unknown = opts.keys - allowed
raise ArgumentError, "unknown proxy options: #{unknown.inspect}" unless unknown.empty?

Type guard

def valid_proxy_opts?(opts)
  opts.is_a?(Hash) && (opts.keys - Selenium::WebDriver::Proxy::ALLOWED.keys).empty?
end

Try / catch

begin
  proxy = Selenium::WebDriver::Proxy.new(opts)
rescue ArgumentError => e
  raise unless e.message.include?('unknown option')
  allowed = Selenium::WebDriver::Proxy::ALLOWED.keys
  proxy = Selenium::WebDriver::Proxy.new(opts.slice(*allowed))
end

Prevention

When it happens

Trigger: Calling Proxy.new(ftp: 'host:port') since ftp is not a supported key. A typo such as :htp or :ssl_proxy. Passing a generic capabilities hash that includes unrelated keys.

Common situations: Assuming an FTP proxy key exists. Copying keys from another library's proxy config. Merging an options hash that contains non-proxy entries.

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/5603140b4982deaa. Report an issue: GitHub.