{"record":{"id":"cb2e74208ce507c2","repo":"balderdashy/sails","slug":"cannot-call-res-render-req-sails-was-not-at","errorCode":null,"errorMessage":"Cannot call res.render() - `req._sails` was not attached","messagePattern":"Cannot call res\\.render\\(\\) - `req\\._sails` was not attached","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/router/res.js","lineNumber":321,"sourceCode":"    // (Otherwise, we can just rely on `send` to do that for us.)\n    if (_.isString(data)) {\n      data = JSON.stringify(data);\n      res.set('content-type', 'application/json');\n    }\n\n    return res.status(res.statusCode || 200).send(data);\n  };\n\n  // res.render()\n  res.render = res.render || function _renderShim (relativeViewPath, locals, cb) {\n    if (_.isFunction(locals)) {\n      cb = locals;\n      locals = {};\n    }\n\n    try {\n      if (!req._sails) {\n        throw new Error('Cannot call res.render() - `req._sails` was not attached');\n      }\n      if (!req._sails.renderView) {\n        throw new Error('Cannot call res.render() - `req._sails.renderView` was not attached (perhaps `views` hook is not enabled?)');\n      }\n\n      res.set('content-type', 'text/html');\n\n      // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n      // TODO:\n      // Instead of this shim, turn `sails.renderView` into something like\n      // `sails.hooks.views.render()`, and then call it.\n      throw flaverr({statusCode: 501}, new Error('Not implemented in core yet'));\n      //\n      // Instead, do something like the following:\n      // ```\n      // var html;\n      // // ...\n      // if (cb) {","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/router/res.js#L303-L339","documentation":"Error \"Cannot call res.render() - `req._sails` was not attached\" thrown in balderdashy/sails.","triggerScenarios":"Thrown at lib/router/res.js:321 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}