{"record":{"id":"9c86b72018e5f68d","repo":"SeleniumHQ/selenium","slug":"status-code-response-code-payload-response-p","errorCode":null,"errorMessage":"status code #{response.code}; payload #{response.payload}","messagePattern":"status code #(.+?); payload #(.+?)","errorType":"exception","errorClass":"Error::ServerError","httpStatus":null,"severity":"critical","filePath":"rb/lib/selenium/webdriver/remote/response.rb","lineNumber":56,"sourceCode":"          error, message, backtrace = process_error\n          klass = Error.for_error(error) || return\n          ex = klass.new(message)\n          add_cause(ex, error, backtrace)\n          ex\n        end\n\n        def [](key)\n          @payload[key]\n        end\n\n        private\n\n        def assert_ok\n          e = error\n          raise e if e\n          return unless @code.nil? || @code >= 400\n\n          raise Error::ServerError, self\n        end\n\n        def add_cause(ex, error, backtrace)\n          cause = Error::WebDriverError.new\n          backtrace = backtrace_from_remote(backtrace) if backtrace.is_a?(Array)\n          cause.set_backtrace(backtrace)\n          raise ex, cause: cause\n        rescue Error.for_error(error)\n          ex\n        end\n\n        def backtrace_from_remote(server_trace)\n          server_trace.filter_map do |frame|\n            next unless frame.is_a?(Hash)\n\n            file = frame['fileName']\n            line = frame['lineNumber']\n            method = frame['methodName']","sourceCodeStart":38,"sourceCodeEnd":74,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/rb/lib/selenium/webdriver/remote/response.rb#L38-L74","documentation":"Raised as Error::ServerError by Response#assert_ok when the HTTP response code is >= 400 (or nil) AND the response payload does not contain a recognized W3C error name that Error.for_error can map. assert_ok first tries to extract a specific error (e.g. NoSuchElementError) from the payload's value.error field; if unmapped, it falls back to ServerError with the raw status code and payload for diagnosis. This is the catch-all for unmapped server-side failures.","triggerScenarios":"The remote server returns a 5xx status with a payload whose 'error' field is not in the W3C error name table (Error.for_error returns nil). A 4xx with a non-standard error body. A server bug producing an unexpected status code. The server returns an error in a legacy (non-W3C) format that the error mapper doesn't recognize.","commonSituations":"Selenium Server / Grid internal errors (500) with non-standard error payloads. Non-W3C-compliant remote endpoints (older Selenium 2 servers, third-party services). Transient server-side failures during heavy load. Browser driver crashes producing unmapped errors. Network-layer issues surfaced as HTTP errors by the server.","solutions":["Inspect the full error message — it includes the status code and payload, which usually reveals the server-side problem.","Check Selenium Server / Grid logs for the matching error at the same timestamp.","If the status is 5xx and intermittent, retry with backoff — it may be a transient server overload.","Update the Selenium Server/Grid and client gem to matching versions to ensure error name compatibility.","If using a third-party remote endpoint, consult its docs for the non-standard error format."],"exampleFix":"# ServerError includes the code + payload; log it for diagnosis:\n# begin\n#   driver.find_element(id: 'missing')\n# rescue Selenium::WebDriver::Error::ServerError => e\n#   puts e.message  # \"status code 500; payload {\\\"value\\\":{\\\"error\\\":\\\"unknown error\\\",...}}\"\n#   # check grid logs, retry if transient\n# end\n#\n# For transient 5xx, wrap with retry:\n# retries = 0\n# begin\n#   driver.navigate.to(url)\n# rescue Selenium::WebDriver::Error::ServerError => e\n#   raise if retries >= 3\n#   retries += 1\n#   sleep 2 ** retries\n#   retry\n# end","handlingStrategy":"try-catch","validationCode":"# No caller-side prevention for unmapped server errors, but you can pre-check server health:\nrequire 'net/http'\nresp = Net::HTTP.get_response(URI(server_url + '/status'))\nraise 'Grid not ready' unless JSON.parse(resp.body)['value']['ready']","typeGuard":null,"tryCatchPattern":"retries = 0\nbegin\n  driver.find_element(id: target)\nrescue Selenium::WebDriver::Error::ServerError => e\n  # e.message includes the status code and payload for diagnosis\n  raise if retries >= 3 || !e.message.match?(/status code 5\\d\\d/)\n  retries += 1\n  sleep 2 ** retries\n  retry\nend","preventionTips":["Always log the full ServerError message — the payload reveals the server-side cause.","Check Selenium Server / Grid logs at the matching timestamp.","Implement retry with exponential backoff for transient 5xx ServerErrors.","Keep the Selenium Server/Grid and client gem versions aligned for error-name compatibility.","Monitor grid health via the /status endpoint proactively."],"tags":["server-error","http-response","error-mapping","w3c","catch-all"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}