{"record":{"id":"f51bfd8112bee13d","repo":"SeleniumHQ/selenium","slug":"value-must-be-an-instance-of-bytesvalue-received-f51bfd","errorCode":null,"errorMessage":"Value must be an instance of BytesValue. Received:'${value}'","messagePattern":"Value must be an instance of BytesValue\\. Received:'(.+?)'","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/bidi/cookieFilter.js","lineNumber":47,"sourceCode":"   *\n   * @param {string} name - The name of the cookie.\n   * @returns {CookieFilter} - The updated CookieFilter instance for chaining.\n   */\n  name(name) {\n    this.#map.set('name', name)\n    return this\n  }\n\n  /**\n   * Sets the value of the cookie.\n   *\n   * @param {BytesValue} value - The value to be set. Must be an instance of BytesValue.\n   * @returns {CookieFilter} - The updated CookieFilter instance for chaining.\n   * @throws {Error} - If the value is not an instance of BytesValue.\n   */\n  value(value) {\n    if (!(value instanceof BytesValue)) {\n      throw new Error(`Value must be an instance of BytesValue. Received:'${value}'`)\n    }\n    this.#map.set('value', Object.fromEntries(value.asMap()))\n    return this\n  }\n\n  /**\n   * Sets the domain for the cookie.\n   *\n   * @param {string} domain - The domain to set.\n   * @returns {CookieFilter} - The updated CookieFilter instance for chaining.\n   */\n  domain(domain) {\n    this.#map.set('domain', domain)\n    return this\n  }\n\n  /**\n   * Sets the url path for the cookie to be fetched.","sourceCodeStart":29,"sourceCodeEnd":65,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/bidi/cookieFilter.js#L29-L65","documentation":"Thrown by `CookieFilter.value()` when the argument is not a `BytesValue` instance. The method calls `value.asMap()` to serialize the cookie value into the getCookies filter, so it requires a real `BytesValue` carrying a type and value — a raw string is rejected.","triggerScenarios":"Calling `filter.value('sessionid')` with a raw string; passing `{type:'string', value:'x'}`; reusing a Cookie's value getter without confirming it is a BytesValue.","commonSituations":"Developers assume a plain string cookie value works; building a filter from deserialized cookie data.","solutions":["Wrap the value in `new BytesValue(BytesValue.Type.STRING, value)`","Import `{ BytesValue }` from `selenium-webdriver/bidi/networkTypes`","value() is optional in CookieFilter — omit it if you do not have a BytesValue"],"exampleFix":"// before\nfilter.value('sessionid')\n// after\nconst { BytesValue } = require('selenium-webdriver/bidi/networkTypes')\nfilter.value(new BytesValue(BytesValue.Type.STRING, 'sessionid'))","handlingStrategy":"type-guard","validationCode":"const { BytesValue } = require('selenium-webdriver/bidi/networkTypes')\nif (value instanceof BytesValue) filter.value(value)","typeGuard":"const { BytesValue } = require('selenium-webdriver/bidi/networkTypes')\nconst isBytesValue = (v) => v instanceof BytesValue","tryCatchPattern":null,"preventionTips":["Cookie values in filters must be BytesValue, not raw strings","value() is optional in CookieFilter — omit it if you don't have a BytesValue"],"tags":["bidi","storage","validation","bytes-value","cookie","type-check"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}