{"record":{"id":"ccd9611721737539","repo":"balderdashy/sails","slug":"res-guessview-is-deprecated-in-sails-v1-0","errorCode":null,"errorMessage":"`res.guessView()` is deprecated in Sails >= v1.0.  If you want to continue to use it\nin your Sails app, please just drop its implementation into a hook.\n [?] Unsure or need advice?  Stop by https://sailsjs.com/support","messagePattern":"`res\\.guessView\\(\\)` is deprecated in Sails >= v1\\.0\\.  If you want to continue to use it\nin your Sails app, please just drop its implementation into a hook\\.\n \\[\\?\\] Unsure or need advice\\?  Stop by https://sailsjs\\.com/support","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"lib/hooks/views/res.view.js","lineNumber":46,"sourceCode":"  // ```\n  // function (req,res,next) { _addResViewMethod(req,res); next(); }\n  // ```\n  // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -\n\n\n\n  /**\n   * res.guessView([locals], [couldNotGuessCb])\n   *\n   * @param  {Object} locals\n   * @param  {Function} couldNotGuessCb\n   */\n  res.guessView = function (locals, couldNotGuessCb) {\n\n    // - - - - - - - - - - - - - - - - - - - - - - - - - - -\n    // FUTURE: Completely remove res.guessView()\n    // - - - - - - - - - - - - - - - - - - - - - - - - - - -\n    sails.log.warn(\n      '`res.guessView()` is deprecated in Sails >= v1.0.  If you want to continue to use it\\n'+\n      'in your Sails app, please just drop its implementation into a hook.\\n'+\n      ' [?] Unsure or need advice?  Stop by https://sailsjs.com/support'\n    );\n\n    return res.view(locals, function viewReady(err, html) {\n\n      // If this is an \"implied view doesn't exist\" error,\n      // just serve JSON instead.\n      if (err && (err.code === 'E_VIEW_INFER' || err.code === 'E_VIEW_FAILED')) {\n        return (couldNotGuessCb||res.serverError)(err);\n      }\n\n      // But if some other sort of error occurred, call `res.serverError`\n      else if (err) {return res.serverError(err);}\n\n      // Otherwise we're good, serve the view\n      return res.send(html);","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/hooks/views/res.view.js#L28-L64","documentation":"`res.guessView()` was removed as a first-class API in Sails v1.0. Calling it now logs this deprecation warning but still works temporarily by delegating to `res.view()` with a guessed path. The supported path is to implement the guessing logic yourself inside a custom hook.","triggerScenarios":"Any request handler or policy calling `res.guessView(locals, cb)` in a Sails >= 1.0 app, typically code upgraded from 0.12.","commonSituations":"Legacy 0.12 apps lifted on Sails 1.x after `sails lift` migration; old error-handling code that guessed view paths based on request headers.","solutions":["Replace `res.guessView()` with explicit `res.view(path, locals)` calls","Move the guessView implementation into a custom hook that attaches it to res","Remove the call if unused"],"exampleFix":"// before\nres.guessView(locals, function(err, html) { ... });\n// after\nres.view('homepage', locals, function(err, html) { ... });","handlingStrategy":"fallback","validationCode":"if (typeof res.guessView === 'function' && !res.guessView.__warned) {\n  console.warn('res.guessView is deprecated; migrate to res.view(path, locals)');\n}","typeGuard":null,"tryCatchPattern":"try {\n  res.guessView(locals, cb);\n} catch (err) {\n  res.view('fallback-view', locals, cb); // supported API fallback\n}","preventionTips":["Replace res.guessView with explicit res.view calls during 0.12 -> 1.x migration","Implement view-guessing in a custom hook if still needed","Grep legacy code for guessView before upgrading"],"tags":["deprecation","views","res","sails"],"backgroundTag":"deprecated-api-usage","analyzedSha":"7b76422cc27823df033572bdda5c4910a68b697f","analyzedAt":"2026-09-01T04:01:57.104Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}