{"record":{"id":"560ce38bed8e5a15","repo":"SeleniumHQ/selenium","slug":"password-must-be-a-string-received-password","errorCode":null,"errorMessage":"Password must be a string. Received:'${password}'","messagePattern":"Password must be a string\\. Received:'(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/bidi/continueResponseParameters.js","lineNumber":65,"sourceCode":"    this.#map.set('cookies', cookies)\n    return this\n  }\n\n  /**\n   * Sets the credentials for authentication.\n   *\n   * @param {string} username - The username for authentication.\n   * @param {string} password - The password for authentication.\n   * @returns {ContinueResponseParameters} The current instance of the ContinueResponseParameters for chaining.\n   * @throws {Error} If username or password is not a string.\n   */\n  credentials(username, password) {\n    if (typeof username !== 'string') {\n      throw new Error(`Username must be a string. Received:'${username}'`)\n    }\n\n    if (typeof password !== 'string') {\n      throw new Error(`Password must be a string. Received:'${password}'`)\n    }\n\n    this.#map.set('credentials', { type: 'password', username: username, password: password })\n\n    return this\n  }\n\n  /**\n   * Sets the headers for the response.\n   *\n   * @param {Header[]} headers - An array of Header objects representing the headers.\n   * @returns {ContinueResponseParameters} - The current instance of the ContinueResponseParameters for chaining.\n   * @throws {Error} - If the header value is not an instance of Header.\n   */\n  headers(headers) {\n    const headerList = []\n    headers.forEach((header) => {\n      if (!(header instanceof Header)) {","sourceCodeStart":47,"sourceCodeEnd":83,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/bidi/continueResponseParameters.js#L47-L83","documentation":"Thrown by `ContinueResponseParameters.credentials()` when the second argument (password) is not a string. Because username is validated first, a bad username throws [27] before this one can fire; this error means the username was valid but the password was not a string.","triggerScenarios":"Calling `params.credentials('user', undefined)` or `params.credentials('user', 123)`.","commonSituations":"Password from an env var that is unset; passing a secret-manager object/result instead of the resolved string value.","solutions":["Pass a string password: `params.credentials('user', 'pass')`","Resolve the secret to a string before calling"],"exampleFix":"// before\nparams.credentials('user', secretFromManager)\n// after\nparams.credentials('user', String(secretFromManager))","handlingStrategy":"validation","validationCode":"if (typeof password === 'string') params.credentials(username, password)","typeGuard":"const isPasswordString = (p) => typeof p === 'string'","tryCatchPattern":null,"preventionTips":["Resolve secrets to plain strings before passing","Note username is validated before password, so fix [27] first"],"tags":["bidi","network-interception","validation","string","credentials"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}