{"record":{"id":"00cd6bbdad329a3e","repo":"SeleniumHQ/selenium","slug":"cannot-use-both-http-client-and-client-config","errorCode":null,"errorMessage":"Cannot use both :http_client and :client_config","messagePattern":"Cannot use both :http_client and :client_config","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/common/local_driver.rb","lineNumber":65,"sourceCode":"\n        unless options.is_a?(default_options.class)\n          raise ArgumentError, \":options must be an instance of #{default_options.class}\"\n        end\n\n        finder = WebDriver::DriverFinder.new(options, service)\n        options.binary = finder.browser_path if options.respond_to?(:binary) && finder.browser_path?\n        service.executable_path = finder.driver_path\n        options.browser_version = nil if options.respond_to?(:binary) && options.binary\n        options.as_json\n      end\n\n      private\n\n      def assert_local_arguments(url, http_client, client_config)\n        if url || client_config&.server_url\n          raise ArgumentError, \"Can't set the server URL for #{self.class}; the service provides it\"\n        elsif http_client && client_config\n          raise ArgumentError, 'Cannot use both :http_client and :client_config'\n        end\n      end\n    end\n  end\nend\n","sourceCodeStart":47,"sourceCodeEnd":71,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/common/local_driver.rb#L47-L71","documentation":"A local driver accepts HTTP configuration through either an :http_client object or a :client_config object, but not both at once. They are alternative, mutually exclusive ways to configure the HTTP transport to the driver service. Passing both raises ArgumentError.","triggerScenarios":"Calling Selenium::WebDriver.for(:chrome, http_client: client, client_config: config). Building a ClientConfig for timeouts and also passing a custom Http::Default client.","commonSituations":"Gradually migrating from http_client-based configuration to client_config and leaving both in the hash. Merging two configuration sources without deduplication.","solutions":["Choose one mechanism: pass only :http_client or only :client_config.","If you need timeouts/URL settings, encode them in the ClientConfig and drop the http_client argument.","If you have a custom HTTP client subclass, pass it via :http_client alone."],"exampleFix":"# before\ndriver = Selenium::WebDriver.for(:chrome, http_client: client, client_config: config)\n\n# after\ndriver = Selenium::WebDriver.for(:chrome, client_config: config)","handlingStrategy":"validation","validationCode":"raise ArgumentError, 'pass either http_client or client_config, not both' if http_client && client_config","typeGuard":null,"tryCatchPattern":"begin\n  Selenium::WebDriver.for(:chrome, http_client: hc, client_config: cc)\nrescue ArgumentError => e\n  raise unless e.message.include?('http_client and :client_config')\n  Selenium::WebDriver.for(:chrome, client_config: cc)\nend","preventionTips":["Decide on a single HTTP configuration mechanism for the whole project.","When migrating from http_client to client_config, remove the old argument.","Validate the options hash does not contain both keys before driver creation."],"tags":["ruby","driver-init","http-client","configuration"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}