{"record":{"id":"4f03d7326cc8becb","repo":"SeleniumHQ/selenium","slug":"cannot-use-both-client-config-and-open-timeout","errorCode":null,"errorMessage":"Cannot use both :client_config and :open_timeout/:read_timeout","messagePattern":"Cannot use both :client_config and :open_timeout/:read_timeout","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/http/default.rb","lineNumber":35,"sourceCode":"# specific language governing permissions and limitations\n# under the License.\nrequire 'ipaddr'\n\nmodule Selenium\n  module WebDriver\n    module Remote\n      module Http\n        # @api private\n        class Default < Common\n          # Initializes object.\n          # Warning: Setting {#open_timeout} to non-nil values will cause a separate thread to spawn.\n          # Debuggers that freeze the process will not be able to evaluate any operations if that happens.\n          # @param [ClientConfig] client_config - Configuration used to build the HTTP client.\n          # @param [Numeric] open_timeout - Open timeout to apply to HTTP client.\n          # @param [Numeric] read_timeout - Read timeout (seconds) to apply to HTTP client.\n          def initialize(client_config: nil, open_timeout: nil, read_timeout: nil)\n            if client_config && (open_timeout || read_timeout)\n              raise ArgumentError, 'Cannot use both :client_config and :open_timeout/:read_timeout'\n            end\n\n            client_config ||= ClientConfig.new\n            client_config.open_timeout = open_timeout if open_timeout\n            client_config.read_timeout = read_timeout if read_timeout\n            super(client_config: client_config)\n          end\n\n          def open_timeout\n            client_config.open_timeout\n          end\n\n          def read_timeout\n            client_config.read_timeout\n          end\n\n          def open_timeout=(value)\n            client_config.open_timeout = value","sourceCodeStart":17,"sourceCodeEnd":53,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/http/default.rb#L17-L53","documentation":"Raised by Http::Default#initialize when both :client_config and :open_timeout or :read_timeout keyword arguments are provided. The Default client builds its HTTP configuration from a single ClientConfig object; passing standalone timeouts alongside a client_config creates ambiguity about which timeout value wins, so the constructor rejects the combination outright.","triggerScenarios":"Calling Selenium::WebDriver::Remote::Http::Default.new(client_config: config, open_timeout: 30). Passing read_timeout from a shared config hash while also providing a client_config. Migrating to client_config but leaving old timeout kwargs in the call.","commonSituations":"Migration from the legacy open_timeout/read_timeout constructor args to the client_config API. Config builders that set timeouts on the client_config AND pass them as kwargs. Copy-pasting from different gem versions' documentation.","solutions":["Set timeouts on the ClientConfig object only: ClientConfig.new(open_timeout: 30, read_timeout: 60).","Or use the legacy standalone timeouts without client_config: Default.new(open_timeout: 30).","When building client_config dynamically, merge timeout values into it rather than passing them separately."],"exampleFix":"# before\nclient = Selenium::WebDriver::Remote::Http::Default.new(\n  client_config: config, open_timeout: 30)\n\n# after\nconfig.open_timeout = 30\nclient = Selenium::WebDriver::Remote::Http::Default.new(client_config: config)","handlingStrategy":"validation","validationCode":"# Ensure only one timeout config source:\nif config[:client_config] && (config[:open_timeout] || config[:read_timeout])\n  raise ArgumentError, 'Use either :client_config or :open_timeout/:read_timeout, not both'\nend","typeGuard":"def single_timeout_config?(config)\n  !(config[:client_config] && (config[:open_timeout] || config[:read_timeout]))\nend","tryCatchPattern":"begin\n  Selenium::WebDriver::Remote::Http::Default.new(**config)\nrescue ArgumentError => e\n  raise unless e.message.include?('client_config')\n  config[:client_config].open_timeout = config.delete(:open_timeout)\n  config[:client_config].read_timeout = config.delete(:read_timeout)\n  Selenium::WebDriver::Remote::Http::Default.new(**config)\nend","preventionTips":["Set timeouts on ClientConfig, not as standalone kwargs when using client_config.","Standardize on ClientConfig for all HTTP client configuration.","Audit config builders for conflicting timeout keys."],"tags":["argument-error","http-client","client-config","timeout","config-mistake"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}