{"record":{"id":"532c4afcdf4acea3","repo":"SeleniumHQ/selenium","slug":"params-must-be-an-instance-of-cookiefilter-receiv-532c4a","errorCode":null,"errorMessage":"Params must be an instance of CookieFilter. Received:'${cookieFilter}'","messagePattern":"Params must be an instance of CookieFilter\\. Received:'(.+?)'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/bidi/storage.js","lineNumber":160,"sourceCode":"        Object.prototype.hasOwnProperty.call(response.result.partitionKey, 'userContext') &&\n        Object.prototype.hasOwnProperty.call(response.result.partitionKey, 'sourceOrigin')\n      ) {\n        return new PartitionKey(response.result.partitionKey.userContext, response.result.partitionKey.sourceOrigin)\n      }\n    }\n  }\n\n  /**\n   * Deletes cookies based on the provided filter and partition.\n   *\n   * @param {CookieFilter} [cookieFilter] - The filter to apply to the cookies. Must be an instance of CookieFilter.\n   * @param {(BrowsingContextPartitionDescriptor|StorageKeyPartitionDescriptor)} [partition] - The partition to delete cookies from. Must be an instance of either BrowsingContextPartitionDescriptor or StorageKeyPartitionDescriptor.\n   * @returns {PartitionKey} - The partition key of the deleted cookies, if available.\n   * @throws {Error} - If the provided parameters are not of the correct type.\n   */\n  async deleteCookies(cookieFilter = undefined, partition = undefined) {\n    if (cookieFilter !== undefined && !(cookieFilter instanceof CookieFilter)) {\n      throw new Error(`Params must be an instance of CookieFilter. Received:'${cookieFilter}'`)\n    }\n\n    if (\n      partition !== undefined &&\n      !(partition instanceof BrowsingContextPartitionDescriptor || partition instanceof StorageKeyPartitionDescriptor)\n    ) {\n      throw new Error(\n        `Params must be an instance of BrowsingContextPartitionDescriptor or StorageKeyPartitionDescriptor. Received:'${partition}'`,\n      )\n    }\n\n    const command = {\n      method: 'storage.deleteCookies',\n      params: {\n        filter: cookieFilter ? Object.fromEntries(cookieFilter.asMap()) : undefined,\n        partition: partition ? Object.fromEntries(partition.asMap()) : undefined,\n      },\n    }","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/bidi/storage.js#L142-L178","documentation":"Thrown by Storage.deleteCookies() (BiDi storage module) when the cookieFilter argument is defined (not undefined) but is not an instance of the CookieFilter class. The WebDriver BiDi protocol requires typed descriptor objects; plain JS objects are rejected. Pass undefined to delete all cookies, or a properly constructed CookieFilter.","triggerScenarios":"Calling storage.deleteCookies({name:'session'}) with a plain object instead of a CookieFilter instance. Passing a string, number, or any non-CookieFilter value as the first argument. Migrating from the classic cookies API where plain objects were accepted.","commonSituations":"Migrating from classic WebDriver cookie APIs to BiDi; passing raw filter objects copied from examples that predate the typed BiDi API; forgetting to import and instantiate CookieFilter.","solutions":["Construct the filter with new CookieFilter() and chain .name()/.domain()/.path()/.httpOnly()/.secure()/.sameSite()/.expiry().","Pass undefined as the first argument to delete all cookies in the partition.","Import CookieFilter from the bidi storage module: const { CookieFilter } = require('selenium-webdriver/bidi/storage')."],"exampleFix":"// before\nstorage.deleteCookies({ name: 'session' })\n// after\nconst { CookieFilter } = require('selenium-webdriver/bidi/storage')\nstorage.deleteCookies(new CookieFilter().name('session'))","handlingStrategy":"type-guard","validationCode":"if (cookieFilter !== undefined && !(cookieFilter instanceof CookieFilter)) {\n  throw new TypeError('cookieFilter must be a CookieFilter instance or undefined')\n}","typeGuard":"/**\n * @param {*} filter\n * @returns {filter is CookieFilter}\n */\nfunction isCookieFilter(filter) {\n  return filter instanceof CookieFilter\n}","tryCatchPattern":null,"preventionTips":["Always construct filters via new CookieFilter() and chain methods; never pass plain objects.","Pass undefined explicitly when you want to delete all cookies.","Import CookieFilter from the bidi/storage module at the top of your file."],"tags":["bidi","validation","cookies","webdriver","type"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}