SeleniumHQ/selenium · error · Error

Params must be an instance of ProvideResponseParameters. Rec

Error message

Params must be an instance of ProvideResponseParameters. Received:'${params}'

What it means

Thrown by Network.provideResponse() when params is not an instance of ProvideResponseParameters. The method calls params.asMap() to build the network.provideResponse BiDi command and therefore requires that exact class. Plain objects or mismatched Parameters classes are rejected by the instanceof guard.

Source

Thrown at javascript/selenium-webdriver/bidi/network.js:352

    const command = {
      method: 'network.continueResponse',
      params: Object.fromEntries(params.asMap()),
    }

    await this.bidi.send(command)
  }

  /**
   * Provides a response for the network.
   *
   * @param {ProvideResponseParameters} params - The parameters for providing the response.
   * @throws {Error} If params is not an instance of ProvideResponseParameters.
   * @returns {Promise<void>} A promise that resolves when the command is sent.
   */
  async provideResponse(params) {
    if (!(params instanceof ProvideResponseParameters)) {
      throw new Error(`Params must be an instance of ProvideResponseParameters. Received:'${params}'`)
    }

    const command = {
      method: 'network.provideResponse',
      params: Object.fromEntries(params.asMap()),
    }

    await this.bidi.send(command)
  }

  /**
   * Sets the cache behavior for network requests.
   *
   * @param {string} behavior - The cache behavior ("default" or "bypass")
   * @param {Array<string>} [contexts] - Optional array of browsing context IDs
   * @returns {Promise<void>} A promise that resolves when the cache behavior is set
   * @throws {Error} If behavior is invalid or context IDs are invalid
   */

View on GitHub (pinned to aa36b38e69)

Solutions

  1. Build a ProvideResponseParameters instance, configure statusCode/reasonPhrase/headers/body/cookies, then call provideResponse(params).
  2. Pass the Parameters instance, never a raw object or id.
  3. Confirm the class name matches the method: ProvideResponseParameters for provideResponse.

Example fix

// before
await network.provideResponse({ request: id, statusCode: 200 })

// after
const params = new ProvideResponseParameters(id)
  .statusCode(200)
  .reasonPhrase('OK')
await network.provideResponse(params)
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(params instanceof ProvideResponseParameters)) {
  throw new TypeError('provideResponse requires ProvideResponseParameters')
}

Type guard

function isProvideResponseParameters(v) {
  return v instanceof ProvideResponseParameters
}

Try / catch

try {
  await network.provideResponse(params)
} catch (e) {
  if (/instance of ProvideResponseParameters/.test(e.message)) {
    // rebuild as ProvideResponseParameters
  } else throw e
}

Prevention

When it happens

Trigger: Calling network.provideResponse({...}) with a literal object; passing the network id string directly; passing a ContinueResponseParameters instance by mistake.

Common situations: Mocking/providing a full response and passing a hand-built object instead of the typed builder; confusing provideResponse (full synthetic response) with continueResponse (forward with overrides).

Related errors


AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14). Data as JSON: /api/errors/2acf92401d888831. Report an issue: GitHub.