{"record":{"id":"f9b4778110cfbb9a","repo":"SeleniumHQ/selenium","slug":"invalid-url-aurl","errorCode":null,"errorMessage":"Invalid URL: ${aUrl}","messagePattern":"Invalid URL: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/http/index.js","lineNumber":51,"sourceCode":" *            auth: (?string|undefined),\n *            hostname: (?string|undefined),\n *            host: (?string|undefined),\n *            port: (?string|undefined),\n *            path: (?string|undefined),\n *            pathname: (?string|undefined)}}\n */\nlet RequestOptions // eslint-disable-line\n\n/**\n * @param {string} aUrl The request URL to parse.\n * @return {RequestOptions} The request options.\n * @throws {Error} if the URL does not include a hostname.\n */\nfunction getRequestOptions(aUrl) {\n  // eslint-disable-next-line n/no-deprecated-api\n  let options = url.parse(aUrl)\n  if (!options.hostname) {\n    throw new Error('Invalid URL: ' + aUrl)\n  }\n  // Delete the search and has portions as they are not used.\n  options.search = null\n  options.hash = null\n  options.path = options.pathname\n  options.hostname = options.hostname === 'localhost' ? '127.0.0.1' : options.hostname // To support Node 17 and above. Refer https://github.com/nodejs/node/issues/40702 for details.\n  return options\n}\n\n/** @const {string} */\nconst USER_AGENT = (function () {\n  const version = require('../package.json').version\n  const platform = { darwin: 'mac', win32: 'windows' }[process.platform] || 'linux'\n  return `selenium/${version} (js ${platform})`\n})()\n\n/**\n * A basic HTTP client used to send messages to a remote end.","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/http/index.js#L33-L69","documentation":"Thrown by getRequestOptions() in http/index.js when url.parse(aUrl) yields no hostname. The HttpClient constructor calls this to validate the server URL. Any URL lacking a host (relative path, empty string, missing scheme) fails this check.","triggerScenarios":"Passing 'localhost:4444' without the http:// scheme to new HttpClient() or Builder.usingServer(). SELENIUM_REMOTE_URL set to a malformed value. Passing an empty string, a bare path, or undefined coerced to string.","commonSituations":"Forgetting the http:// or https:// scheme; reading a server URL from config that omits the scheme; SELENIUM_REMOTE_URL typo; passing a Grid URL constructed by string concatenation that drops the scheme.","solutions":["Include the scheme and host: 'http://localhost:4444'.","Verify the SELENIUM_REMOTE_URL environment variable value.","Validate the URL with new URL(urlString) before passing it.","Ensure Builder.usingServer() receives a fully-qualified URL."],"exampleFix":"// before\nnew Builder().usingServer('localhost:4444').build()\n// after\nnew Builder().usingServer('http://localhost:4444').build()","handlingStrategy":"validation","validationCode":"function assertValidServerUrl(urlString) {\n  let parsed\n  try {\n    parsed = new URL(urlString)\n  } catch {\n    throw new Error(`Invalid server URL (unparseable): ${urlString}`)\n  }\n  if (!parsed.hostname) {\n    throw new Error(`Invalid server URL (no hostname): ${urlString}`)\n  }\n  return urlString\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always include the http:// or https:// scheme in server URLs.","Validate URLs with new URL() before passing to usingServer() or new HttpClient().","Check SELENIUM_REMOTE_URL at startup and fail fast with a clear message.","Prefer fully-qualified URLs from configuration over string concatenation."],"tags":["http","validation","url","configuration","remote"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}