{"record":{"id":"6fc90e72f23a8843","repo":"SeleniumHQ/selenium","slug":"status-must-be-an-integer-received-statuscode-6fc90e","errorCode":null,"errorMessage":"Status must be an integer. Received:'${statusCode}'","messagePattern":"Status must be an integer\\. Received:'(.+?)'","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"javascript/selenium-webdriver/bidi/provideResponseParameters.js","lineNumber":111,"sourceCode":"   */\n  reasonPhrase(reasonPhrase) {\n    if (typeof reasonPhrase !== 'string') {\n      throw new Error(`Reason phrase must be a string. Received: '${reasonPhrase})'`)\n    }\n    this.#map.set('reasonPhrase', reasonPhrase)\n    return this\n  }\n\n  /**\n   * Sets the status code for the response.\n   *\n   * @param {number} statusCode - The status code to set.\n   * @returns {ProvideResponseParameters} - Returns the ProvideResponseParameters object for chaining.\n   * @throws {Error} - If the status code is not an integer.\n   */\n  statusCode(statusCode) {\n    if (!Number.isInteger(statusCode)) {\n      throw new Error(`Status must be an integer. Received:'${statusCode}'`)\n    }\n\n    this.#map.set('statusCode', statusCode)\n    return this\n  }\n\n  asMap() {\n    return this.#map\n  }\n}\n\nmodule.exports = { ProvideResponseParameters }\n","sourceCodeStart":93,"sourceCodeEnd":124,"githubUrl":"https://github.com/SeleniumHQ/selenium/blob/aa36b38e696a0909e973bdf5e2f9031ffe842c4b/javascript/selenium-webdriver/bidi/provideResponseParameters.js#L93-L124","documentation":"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.","triggerScenarios":"Calling params.statusCode('200') (string), params.statusCode(200.5) (float), params.statusCode(null), params.statusCode(NaN), or params.statusCode(true).","commonSituations":"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.","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."],"exampleFix":"// before\nconst params = new ProvideResponseParameters(id).statusCode('200')\n\n// after\nconst params = new ProvideResponseParameters(id).statusCode(200)","handlingStrategy":"validation","validationCode":"if (!Number.isInteger(statusCode)) {\n  throw new TypeError('statusCode must be an integer')\n}","typeGuard":"function isHttpStatusCode(v) {\n  return Number.isInteger(v) && v >= 100 && v <= 599\n}","tryCatchPattern":null,"preventionTips":["Parse status from strings with Number.parseInt and validate with Number.isInteger.","Never pass floats, NaN, null, or booleans.","Optionally range-check 100-599."],"tags":["bidi","network","provide-response","integer-validation","javascript"],"backgroundTag":null,"analyzedSha":"aa36b38e696a0909e973bdf5e2f9031ffe842c4b","analyzedAt":"2026-08-14T02:32:32.244Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}