{"record":{"id":"265df4f5371ac210","repo":"SeleniumHQ/selenium","slug":"reason-phrase-must-be-a-string-received-reaso","errorCode":null,"errorMessage":"Reason phrase must be a string. Received: '${reasonPhrase})'","messagePattern":"Reason phrase must be a string\\. Received: '(.+?)\\)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/bidi/continueResponseParameters.js","lineNumber":102,"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 reason phrase for the response.\n   *\n   * @param {string} reasonPhrase - The reason phrase for the response.\n   * @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.\n   * @throws {Error} - If the reason phrase is not a string.\n   */\n  reasonPhrase(reasonPhrase) {\n    if (typeof reasonPhrase !== 'string') {\n      throw new Error(`Reason phrase must be a string. Received: '${reasonPhrase})'`)\n    }\n    this.#map.set('reasonPhrase', reasonPhrase)\n    return this\n  }\n\n  /**\n   * Sets the status code for the response.\n   *\n   * @param {number} statusCode - The status code to set.\n   * @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.\n   * @throws {Error} - If the `statusCode` parameter is not an integer.\n   */\n  statusCode(statusCode) {\n    if (!Number.isInteger(statusCode)) {\n      throw new Error(`Status must be an integer. Received:'${statusCode}'`)\n    }\n\n    this.#map.set('statusCode', statusCode)","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/bidi/continueResponseParameters.js#L84-L120","documentation":"Thrown by `ContinueResponseParameters.reasonPhrase()` when the argument is not a string (`typeof reasonPhrase !== 'string'`). The value is stored directly into the command map. The error string carries a cosmetic typo: an extra `)` (`'${reasonPhrase})'`).","triggerScenarios":"Calling `params.reasonPhrase(undefined)`, `params.reasonPhrase(200)`, or passing an object.","commonSituations":"Reason phrase omitted (undefined) when only the status code was intended; numeric status confused with the reason phrase.","solutions":["Pass a plain string like 'OK', 'Not Found'","If you only need the status code, omit the reasonPhrase() call entirely — it is optional"],"exampleFix":"// before\nparams.reasonPhrase()\n// after\nparams.reasonPhrase('OK')","handlingStrategy":"validation","validationCode":"if (typeof reason === 'string') params.reasonPhrase(reason)","typeGuard":"const isReasonString = (r) => typeof r === 'string'","tryCatchPattern":null,"preventionTips":["reasonPhrase() is optional — skip it if you only set statusCode","typeof-check dynamic values before calling"],"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"}