{"record":{"id":"b3234129b09c0b6d","repo":"vercel/next.js","slug":"invalid-response-mocked-res-statuscode","errorCode":null,"errorMessage":"Invalid response ${mocked.res.statusCode}","messagePattern":"Invalid response (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/next/src/server/next-server.ts","lineNumber":1368,"sourceCode":"  }) {\n    const mocked = createRequestResponseMocks({\n      url: urlPath,\n      headers,\n    })\n\n    const handler = this.getRequestHandler()\n    await handler(\n      new NodeNextRequest(mocked.req),\n      new NodeNextResponse(mocked.res)\n    )\n    await mocked.res.hasStreamed\n\n    if (\n      mocked.res.getHeader('x-nextjs-cache') !== 'REVALIDATED' &&\n      mocked.res.statusCode !== 200 &&\n      !(mocked.res.statusCode === 404 && opts.unstable_onlyGenerated)\n    ) {\n      throw new Error(`Invalid response ${mocked.res.statusCode}`)\n    }\n  }\n\n  public async render(\n    req: NodeNextRequest | IncomingMessage,\n    res: NodeNextResponse | ServerResponse,\n    pathname: string,\n    query?: NextParsedUrlQuery,\n    parsedUrl?: NextUrlWithParsedQuery,\n    internal = false\n  ): Promise<void> {\n    return super.render(\n      this.normalizeReq(req),\n      this.normalizeRes(res),\n      pathname,\n      query,\n      parsedUrl,\n      internal","sourceCodeStart":1350,"sourceCodeEnd":1386,"githubUrl":"https://github.com/vercel/next.js/blob/43273a1d21a35646ec43230e05727e18ac258396/packages/next/src/server/next-server.ts#L1350-L1386","documentation":"Thrown in NextNodeServer's on-demand revalidation path after it builds a mocked request/response pair and runs the real request handler against the page. The revalidation is only considered successful when the response is 200, carries the x-nextjs-cache: REVALIDATED header, or is a 404 while unstable_onlyGenerated is set. Any other status code reaches this guard, meaning the page handler rejected the revalidation request.","triggerScenarios":"A mocked handler produced an invalid response status.","commonSituations":"Internal invariant when a mock request result has an unexpected status code.","solutions":["Ensure the mocked/handled response has a valid HTTP status code; check custom server or middleware response handling."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"43273a1d21a35646ec43230e05727e18ac258396","analyzedAt":"2026-08-19T02:10:13.922Z","contentChangedAt":"2026-08-19T02:10:13.922Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}