SeleniumHQ/selenium · error · Error
Params must be a value in SameSite. Received:'${sameSite}'
Error message
Params must be a value in SameSite. Received:'${sameSite}' What it means
This message is the *intended* guard in `CookieFilter.sameSite()`, meant to reject values that are not members of the `SameSite` enum. However the guard is malformed: `SameSite` (imported from `networkTypes.js`) is a plain object enum (`{STRICT:'strict', LAX:'lax', NONE:'none', DEFAULT:'default', findByName(){...}}`), not a class/constructor. The expression `sameSite instanceof SameSite` therefore throws `TypeError: Right-hand side of 'instanceof' is not callable` before this message can ever fire — so every call to `.sameSite()` fails with that TypeError regardless of argument, and this error string is effectively unreachable dead code.
Source
Thrown at javascript/selenium-webdriver/bidi/cookieFilter.js:117
*
* @param {boolean} secure - Whether the cookie fetched should be secure only or not.
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
*/
secure(secure) {
this.#map.set('secure', secure)
return this
}
/**
* Sets the SameSite attribute for the cookie.
*
* @param {SameSite} sameSite - The SameSite value to be set for the cookie.
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
* @throws {Error} - If the provided sameSite value is not an instance of SameSite.
*/
sameSite(sameSite) {
if (!(sameSite instanceof SameSite)) {
throw new Error(`Params must be a value in SameSite. Received:'${sameSite}'`)
}
this.#map.set('sameSite', sameSite)
return this
}
/**
* Sets the expiry value.
*
* @param {number} expiry - The expiry value.
* @returns {CookieFilter} - The updated CookieFilter instance for chaining.
*/
expiry(expiry) {
this.#map.set('expiry', expiry)
return this
}
asMap() {
return this.#mapView on GitHub (pinned to aa36b38e69)
Solutions
- Do not call `.sameSite()` — it is optional in CookieFilter; omit it and filter on name/domain/path instead
- Report the bug upstream; the guard should check `['strict','lax','none','default'].includes(sameSite)` rather than `instanceof SameSite`
- As a local workaround, monkeypatch/patch the module to fix the check until a release fixes it
Example fix
// before (throws TypeError on any input)
const { SameSite } = require('selenium-webdriver/bidi/networkTypes')
filter.sameSite(SameSite.LAX)
// after — omit sameSite (it is optional)
filter.name('session').domain('example.com')
// if strictly needed, patch the module or upgrade once the bug is fixed Defensive patterns
Strategy: validation
Validate before calling
// sameSite() is broken (instanceof on a plain object throws TypeError).
// Avoid calling it. If you must validate a value first:
const validSameSite = ['strict', 'lax', 'none', 'default']
if (typeof v === 'string' && validSameSite.includes(v)) {
// do NOT call filter.sameSite() — it throws TypeError; patch or omit
} Type guard
const isSameSiteValue = (v) => ['strict', 'lax', 'none', 'default'].includes(v)
Try / catch
try {
filter.sameSite(value)
} catch (e) {
// Catches the TypeError from the broken instanceof guard.
// Workaround: omit sameSite entirely (it is optional).
} Prevention
- Avoid .sameSite() on CookieFilter until the library bug is fixed — it always throws TypeError
- Validate SameSite values against the string enum, not via instanceof
- sameSite filtering is optional; omit it and use name/domain/path filters
When it happens
Trigger: Calling `filter.sameSite(SameSite.STRICT)` (or any value at all) — every call throws a TypeError from the `instanceof` check, not this Error message. The check should use `Object.values(SameSite).includes(sameSite)` or `SameSite.findByName()` instead of `instanceof`.
Common situations: Any developer who calls `.sameSite()` on a CookieFilter hits the TypeError immediately; this is a library bug, not a usage mistake. The `SameSite.findByName()` helper exists in the enum object but the guard does not use it.
Related errors
- Origin must be one of ${Object.values(Origin)}. Received:'${
- Value must be an instance of BytesValue. Received:'${value}'
- Invalid permission state. Must be one of: ${Object.values(Pe
- Type must be an instance of String. Received:'${type}'
- Quality must be a number. Received:'${quality}'
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/a0c2b4fc16ad6e33.
Report an issue: GitHub.