{"record":{"id":"e13a889ec12b80ab","repo":"balderdashy/sails","slug":"failed-to-stringify-specified-json-response-body","errorCode":null,"errorMessage":"Failed to stringify specified JSON response body :: ' + util.inspect(data) + '\\nError:\\n' + util.inspect(e)","messagePattern":"Failed to stringify specified JSON response body :: ' \\+ util\\.inspect\\(data\\) \\+ '\\\\nError:\\\\n' \\+ util\\.inspect\\(e\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/router/res.js","lineNumber":269,"sourceCode":"\n      try {\n\n        var toWrite;\n\n        // If the data is already a string, don't stringify it.\n        // (This allows for sending plain text, XML, etc.)\n        if (_.isString(data)) {\n          toWrite = data;\n        }\n        else {\n          try {\n            toWrite = JSON.stringify(data);\n            if (!res.get('content-type')) {\n              res.set('content-type', 'application/json');\n            }\n          }\n          catch(e) {\n            throw new Error(\n              'Failed to stringify specified JSON response body :: ' + util.inspect(data) +\n              '\\nError:\\n' + util.inspect(e)\n            );\n          }\n          // if (process.env.NODE_ENV !== 'production') {\n          //   toWrite = e.message;\n          // }\n        }//>-\n\n        res.write(toWrite);\n\n      } catch (e) {\n        if (req._sails && req._sails.log && req._sails.log.error) {\n          req._sails.log.error(e);\n        }\n        else {\n          console.error(e);\n        }","sourceCodeStart":251,"sourceCodeEnd":287,"githubUrl":"https://github.com/balderdashy/sails/blob/7b76422cc27823df033572bdda5c4910a68b697f/lib/router/res.js#L251-L287","documentation":"Error \"Failed to stringify specified JSON response body :: ' + util.inspect(data) + '\\nError:\\n' + util.inspect(e)\" thrown in balderdashy/sails.","triggerScenarios":"Thrown at lib/router/res.js:269 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"}