SeleniumHQ/selenium · error · Error
Status must be an integer. Received:'${statusCode}'
Error message
Status must be an integer. Received:'${statusCode}' What it means
Thrown by ProvideResponseParameters.statusCode() when the statusCode argument is not an integer (fails Number.isInteger). The BiDi response status must be an integer HTTP status code, so floats, strings, NaN, null, or non-numeric values are rejected before serialization.
Source
Thrown at javascript/selenium-webdriver/bidi/provideResponseParameters.js:111
*/
reasonPhrase(reasonPhrase) {
if (typeof reasonPhrase !== 'string') {
throw new Error(`Reason phrase must be a string. Received: '${reasonPhrase})'`)
}
this.#map.set('reasonPhrase', reasonPhrase)
return this
}
/**
* Sets the status code for the response.
*
* @param {number} statusCode - The status code to set.
* @returns {ProvideResponseParameters} - Returns the ProvideResponseParameters object for chaining.
* @throws {Error} - If the status code is not an integer.
*/
statusCode(statusCode) {
if (!Number.isInteger(statusCode)) {
throw new Error(`Status must be an integer. Received:'${statusCode}'`)
}
this.#map.set('statusCode', statusCode)
return this
}
asMap() {
return this.#map
}
}
module.exports = { ProvideResponseParameters }
View on GitHub (pinned to aa36b38e69)
Solutions
- Pass a plain integer, e.g. params.statusCode(200).
- If the value comes from a string source, parse and validate: const code = Number.parseInt(raw, 10); if (Number.isInteger(code)) params.statusCode(code).
- Avoid floats and strings; ensure the value is a JS number with no fractional part.
Example fix
// before
const params = new ProvideResponseParameters(id).statusCode('200')
// after
const params = new ProvideResponseParameters(id).statusCode(200) Defensive patterns
Strategy: validation
Validate before calling
if (!Number.isInteger(statusCode)) {
throw new TypeError('statusCode must be an integer')
} Type guard
function isHttpStatusCode(v) {
return Number.isInteger(v) && v >= 100 && v <= 599
} Prevention
- Parse status from strings with Number.parseInt and validate with Number.isInteger.
- Never pass floats, NaN, null, or booleans.
- Optionally range-check 100-599.
When it happens
Trigger: Calling params.statusCode('200') (string), params.statusCode(200.5) (float), params.statusCode(null), params.statusCode(NaN), or params.statusCode(true).
Common situations: Reading the status from a header/config string and not coercing; passing a float computed from a formula; using a BigInt or boolean where a number is expected.
Related errors
- Params must be an instance of ProvideResponseParameters. Rec
- Value must be an instance of BytesValue. Received: ${typeof
- CookieHeader must be an instance of Header. Received:'${head
- Header must be an instance of Header. Received:'${header}'
- Reason phrase must be a string. Received: '${reasonPhrase})'
AI-assisted analysis of SeleniumHQ/selenium@aa36b38e69 (2026-08-14).
Data as JSON: /api/errors/6fc90e72f23a8843.
Report an issue: GitHub.