{"record":{"id":"c97f08ae4dd44e6a","repo":"SeleniumHQ/selenium","slug":"unknown-error-json-stringify-data","errorCode":null,"errorMessage":"Unknown error: ${JSON.stringify(data)}","messagePattern":"Unknown error: (.+?)","errorType":"exception","errorClass":"WebDriverError","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/lib/error.js","lineNumber":532,"sourceCode":" * if the provided `data` is not a valid encoded error.\n *\n * @param {{error: string, message: string}} data The error data to decode.\n * @throws {WebDriverError} the decoded error.\n * @see https://w3c.github.io/webdriver/webdriver-spec.html#protocol\n */\nfunction throwDecodedError(data) {\n  if (isErrorResponse(data)) {\n    let ctor = ERROR_CODE_TO_TYPE.get(data.error) || WebDriverError\n    let err = new ctor(data.message)\n    // TODO(jleyba): remove whichever case is excluded from the final W3C spec.\n    if (typeof data.stacktrace === 'string') {\n      err.remoteStacktrace = data.stacktrace\n    } else if (typeof data.stackTrace === 'string') {\n      err.remoteStacktrace = data.stackTrace\n    }\n    throw err\n  }\n  throw new WebDriverError('Unknown error: ' + JSON.stringify(data))\n}\n\n/**\n * Checks a legacy response from the Selenium 2.0 wire protocol for an error.\n * @param {*} responseObj the response object to check.\n * @return {*} responseObj the original response if it does not define an error.\n * @throws {WebDriverError} if the response object defines an error.\n */\nfunction checkLegacyResponse(responseObj) {\n  // Handle the legacy Selenium error response format.\n  if (isObject(responseObj) && typeof responseObj.status === 'number' && responseObj.status !== 0) {\n    const { status, value } = responseObj\n\n    let ctor = LEGACY_ERROR_CODE_TO_TYPE.get(status) || WebDriverError\n\n    if (!value || typeof value !== 'object') {\n      throw new ctor(value + '')\n    } else {","sourceCodeStart":514,"sourceCodeEnd":550,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/lib/error.js#L514-L550","documentation":"Thrown by throwDecodedError() in error.js when the response data does not satisfy isErrorResponse() (i.e., it lacks a string `error` field) but was routed to the error-throwing path. The raw data is JSON-stringified into the message. This typically indicates a non-W3C-compliant or malformed response from the remote end.","triggerScenarios":"The remote WebDriver/Grid endpoint returns a response object without an `error` string field where one was expected. A proxy or middleware returns unexpected JSON. A server returns an HTML error page that was parsed into a non-error object. Version mismatch between client expectations and server response shape.","commonSituations":"Misbehaving or outdated Selenium Grid/server; intermediate reverse proxy returning its own error JSON; third-party cloud grid with a non-standard error envelope; server crash returning a non-protocol response.","solutions":["Inspect the JSON-stringified data in the error message to see what the server actually returned.","Verify the remote endpoint URL is correct and points to a WebDriver-compatible server.","Check for intermediate proxies (nginx, corporate proxy) that may inject non-protocol responses.","Upgrade the remote server/Grid to a W3C-compliant version matching the client.","Enable debug logging to capture the raw HTTP response."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  // ... execute WebDriver command ...\n} catch (e) {\n  if (e instanceof WebDriverError && e.message.startsWith('Unknown error:')) {\n    console.error('Non-W3C response from server. Raw data:', e.message)\n    // check server URL, proxy, server version\n  }\n  throw e\n}","preventionTips":["Ensure the remote server/Grid is W3C-compliant and version-compatible with the client.","Verify the endpoint URL and check for intermediate proxies returning non-protocol JSON.","Enable Selenium debug logging to inspect raw HTTP responses during troubleshooting.","Validate the server is reachable and responding with WebDriver protocol responses."],"tags":["error-handling","protocol","remote","webdriver","w3c"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}