{"record":{"id":"aaa2eacb0ed30838","repo":"SeleniumHQ/selenium","slug":"http-method-must-be-a-string-received-method","errorCode":null,"errorMessage":"Http method must be a string. Received: '${method})'","messagePattern":"Http method must be a string\\. Received: '(.+?)\\)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/bidi/continueRequestParameters.js","lineNumber":95,"sourceCode":"        throw new Error(`Header value must be an instance of Header. Received:'${header}'`)\n      }\n      headerList.push(Object.fromEntries(header.asMap()))\n    })\n\n    this.#map.set('headers', headerList)\n    return this\n  }\n\n  /**\n   * Sets the HTTP method for the request.\n   *\n   * @param {string} method - The HTTP method to be set.\n   * @returns {ContinueRequestParameters} - The updated `continueRequestParameters` object.\n   * @throws {Error} - If the method parameter is not a string.\n   */\n  method(method) {\n    if (typeof method !== 'string') {\n      throw new Error(`Http method must be a string. Received: '${method})'`)\n    }\n    this.#map.set('method', method)\n    return this\n  }\n\n  /**\n   * Sets the URL for the request.\n   *\n   * @param {string} url - The URL to set for the request.\n   * @returns {ContinueRequestParameters} - The current instance of the ContinueRequestParameters for chaining.\n   * @throws {Error} - If the url parameter is not a string.\n   */\n  url(url) {\n    if (typeof url !== 'string') {\n      throw new Error(`Url must be a string. Received:'${url}'`)\n    }\n\n    this.#map.set('url', url)","sourceCodeStart":77,"sourceCodeEnd":113,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/bidi/continueRequestParameters.js#L77-L113","documentation":"Thrown by `ContinueRequestParameters.method()` when the argument is not a string (`typeof method !== 'string'`). The method stores the value directly into the BiDi command map. The error string carries a cosmetic typo: an extra `)` (`'${method})'`).","triggerScenarios":"Calling `params.method(undefined)`, `params.method(200)`, or passing a numeric/enum object instead of a string verb.","commonSituations":"Passing a method from a typed enum that resolves to a non-string; forgetting to set the method so it is undefined; confusing an HTTP status number with the method.","solutions":["Pass a plain string such as 'GET', 'POST', 'PUT', 'DELETE'","Ensure the variable is defined and is a string before calling"],"exampleFix":"// before\nparams.method(req.methodNumber)\n// after\nparams.method('POST')","handlingStrategy":"validation","validationCode":"if (typeof method === 'string') params.method(method)","typeGuard":"const isHttpMethod = (m) => typeof m === 'string'","tryCatchPattern":null,"preventionTips":["Use string literals for HTTP methods, not numeric codes","Check typeof before calling when the source is dynamic"],"tags":["bidi","network-interception","validation","string","typo"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}