{"record":{"id":"7e5d2921ea50db5b","repo":"SeleniumHQ/selenium","slug":"cookie-name-cannot-be-null-or-empty-7e5d29","errorCode":null,"errorMessage":"Cookie name cannot be null or empty","messagePattern":"Cookie name cannot be null or empty","errorType":"exception","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"rb/lib/selenium/webdriver/remote/bridge.rb","lineNumber":327,"sourceCode":"        def execute_async_script(script, *args)\n          result = execute :execute_async_script, {}, {script: script, args: args}\n          unwrap_script_result result\n        end\n\n        #\n        # cookies\n        #\n\n        def manage\n          @manage ||= WebDriver::Manager.new(self)\n        end\n\n        def add_cookie(cookie)\n          execute :add_cookie, {}, {cookie: cookie}\n        end\n\n        def delete_cookie(name)\n          raise ArgumentError, 'Cookie name cannot be null or empty' if name.nil? || name.to_s.strip.empty?\n\n          execute :delete_cookie, name: name\n        end\n\n        def cookie(name)\n          execute :get_cookie, name: name\n        end\n\n        def cookies\n          execute :get_all_cookies\n        end\n\n        def delete_all_cookies\n          execute :delete_all_cookies\n        end\n\n        #\n        # actions","sourceCodeStart":309,"sourceCodeEnd":345,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/bridge.rb#L309-L345","documentation":"Raised by Remote::Bridge#delete_cookie (ArgumentError) when the cookie name is nil, empty, or whitespace-only (after strip). The DELETE /cookie/:name endpoint requires a non-empty name, so Selenium validates it client-side before issuing the request.","triggerScenarios":"Calling driver.manage.delete_cookie(name) with nil, '', '   ', or a value that strips to empty; deleting a cookie whose name came from user input or a lookup that returned nil.","commonSituations":"Iterating a list that contains nil/blank names; reading cookie names from external config that may be empty; defensive cleanup code that tries to delete a cookie regardless of whether it exists.","solutions":["Check the name is present and non-blank before calling delete_cookie.","Use delete_all_cookies if you intend to clear everything.","Filter blank/nil entries out of any name list before deletion."],"exampleFix":"// before\nname = cookie_hash[:name]  # may be nil\ndriver.manage.delete_cookie(name)\n\n// after\nname = cookie_hash[:name]\ndriver.manage.delete_cookie(name) if name.is_a?(String) && !name.strip.empty?","handlingStrategy":"validation","validationCode":"if name.is_a?(String) && !name.strip.empty?\n  driver.manage.delete_cookie(name)\nend","typeGuard":"def valid_cookie_name?(name)\n  name.is_a?(String) && !name.strip.empty?\nend","tryCatchPattern":null,"preventionTips":["Check the name is a non-blank string before calling delete_cookie.","Filter nil/blank entries out of any cookie-name list.","Use delete_all_cookies when you intend to clear everything."],"tags":["cookies","argument-error","remote"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}