{"record":{"id":"7ab5dfed7b2531bc","repo":"SeleniumHQ/selenium","slug":"missing-required-parameter-key","errorCode":null,"errorMessage":"Missing required parameter: ${key}","messagePattern":"Missing required parameter: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/webdriver/http/http.js","lineNumber":161,"sourceCode":"webdriver.http.Executor.buildPath_ = function(path, parameters) {\n  var pathParameters = path.match(/\\/:(\\w+)\\b/g);\n  if (pathParameters) {\n    for (var i = 0; i < pathParameters.length; ++i) {\n      var key = pathParameters[i].substring(2);  // Trim the /:\n      if (key in parameters) {\n        var value = parameters[key];\n        // TODO: move webdriver.WebElement.ELEMENT definition to a\n        // common file so we can reference it here without pulling in all of\n        // webdriver.WebElement's dependencies.\n        if (value && value['ELEMENT']) {\n          // When inserting a WebElement into the URL, only use its ID value,\n          // not the full JSON.\n          value = value['ELEMENT'];\n        }\n        path = path.replace(pathParameters[i], '/' + value);\n        delete parameters[key];\n      } else {\n        throw new Error('Missing required parameter: ' + key);\n      }\n    }\n  }\n  return path;\n};\n\n\n/**\n * Callback used to parse {@link webdriver.http.Response} objects from a\n * {@link webdriver.http.Client}.\n * @param {!webdriver.http.Response} httpResponse The HTTP response to parse.\n * @return {!bot.response.ResponseObject} The parsed response.\n * @private\n */\nwebdriver.http.Executor.parseHttpResponse_ = function(httpResponse) {\n  try {\n    return /** @type {!bot.response.ResponseObject} */ (JSON.parse(\n        httpResponse.body));","sourceCodeStart":143,"sourceCodeEnd":179,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/webdriver/http/http.js#L143-L179","documentation":"Thrown as a generic Error by webdriver.http.Executor.buildPath_() when a path template parameter (e.g. :sessionId, :id) has no corresponding value in the command's parameters object. The method iterates over path placeholders extracted from the URL template; for each, it looks up parameters[key]. If the key is absent, it throws 'Missing required parameter: <key>'. This is from the legacy Closure-based HTTP layer.","triggerScenarios":"Executing a command whose path template contains a placeholder (like /session/:sessionId/element/:id) but the command's parameters object does not include a value for 'sessionId' or 'id'. The buildPath_ function cannot substitute the placeholder.","commonSituations":"Constructing a Command manually without setting all required path parameters via setParameter(); a WebElement reference whose ELEMENT/element-6066-11e4-a52e-4f7994e6c44e ID is missing; calling a command before a session has been established (so sessionId is not populated).","solutions":["Ensure every path-template parameter is set on the command: command.setParameter('sessionId', sessionId) and command.setParameter('id', elementId).","If using WebElement objects in parameters, confirm they carry a valid element ID (the code checks for value['ELEMENT'] to extract the ID).","Verify the session has been created before issuing session-scoped commands — the sessionId must be populated.","Log command.getParameters() before execute() to confirm all required keys are present."],"exampleFix":"// before\nvar cmd = new webdriver.command.Command(\n  webdriver.command.Name.FIND_CHILD_ELEMENT\n)\n// missing 'id' parameter\nexecutor.execute(cmd)\n\n// after\nvar cmd = new webdriver.command.Command(\n  webdriver.command.Name.FIND_CHILD_ELEMENT\n)\ncmd.setParameter('sessionId', session.getId())\ncmd.setParameter('id', element.getId())\ncmd.setParameter('using', 'css selector')\ncmd.setParameter('value', '.child')\nexecutor.execute(cmd)","handlingStrategy":"validation","validationCode":"function validateParams(command, requiredKeys) {\n  const params = command.getParameters()\n  for (const key of requiredKeys) {\n    if (!(key in params) || params[key] == null) {\n      throw new Error('Missing path param: ' + key)\n    }\n  }\n}","typeGuard":null,"tryCatchPattern":"try {\n  executor.execute(command)\n} catch (e) {\n  if (/Missing required parameter/.test(e.message)) {\n    // set the missing parameter and retry\n  } else throw e\n}","preventionTips":["Set all path-template parameters via setParameter() before execute().","Ensure a session is established before session-scoped commands.","Log command.getParameters() before executing to verify completeness."],"tags":["javascript","http","path-parameters","command","legacy-webdriver"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}