diff --git a/lib/routes/find.js b/lib/routes/find.js index a66c4ed9..0f3218dd 100644 --- a/lib/routes/find.js +++ b/lib/routes/find.js @@ -36,6 +36,14 @@ findRoute.register = function() { responseHelper._enforceSchemaOnObject(resource, resourceConfig.attributes, callback); }, function(sanitisedData, callback) { + if (!sanitisedData) { + return callback({ + status: "404", + code: "EVERSION", + title: "Resource is not valid", + detail: "The requested resource does not conform to the API specification. This is usually the result of a versioning change." + }); + } response = responseHelper._generateResponse(request, resourceConfig, sanitisedData); response.included = [ ]; postProcess.handle(request, response, callback); diff --git a/lib/routes/relationships.js b/lib/routes/relationships.js index 84910d6f..6c03296a 100644 --- a/lib/routes/relationships.js +++ b/lib/routes/relationships.js @@ -44,6 +44,14 @@ relationshipsRoute.register = function() { responseHelper._enforceSchemaOnObject(resource, resourceConfig.attributes, callback); }, function(sanitisedData, callback) { + if (!sanitisedData) { + return callback({ + status: "404", + code: "EVERSION", + title: "Resource is not valid", + detail: "The requested resource does not conform to the API specification. This is usually the result of a versioning change." + }); + } sanitisedData = sanitisedData.relationships[request.params.relation].data; response = responseHelper._generateResponse(request, resourceConfig, sanitisedData); callback();