trailpack-hapi icon indicating copy to clipboard operation
trailpack-hapi copied to clipboard

Wrong footprint error message

Open jaumard opened this issue 8 years ago • 6 comments

If we call a route like /api/v1/default/toto, I have this error :

debug: [FootprintController] (find) model = default , criteria = {} info options =
Debug: internal, implementation, error 
    TypeError: Uncaught error: Cannot read property 'findOne' of undefined
    at FootprintService.find (/Users/jaumard/Downloads/testTrails/node_modules/trailpack-waterline/api/services/FootprintService.js:46:20)
    at FootprintController.find (/Users/jaumard/Downloads/testTrails/node_modules/trailpack-hapi/api/controllers/FootprintController.js:46:35)
    at result.method.finalize (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:215:20)
    at Object.exports.execute.internals.prerequisites.internals.handler.callback [as handler] (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:96:36)
    at /Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:63:26
    at done (/Users/jaumard/Downloads/testTrails/node_modules/hapi/node_modules/items/lib/index.js:31:25)
    at done (/Users/jaumard/Downloads/testTrails/node_modules/hapi/node_modules/items/lib/index.js:63:25)
    at /Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:49:28
    at finalize (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/handler.js:281:20)
    at wrapped (/Users/jaumard/Downloads/testTrails/node_modules/hapi/node_modules/hoek/lib/index.js:867:20)
    at internals.Response._prepare.internals.Response._processPrepare.next [as _processPrepare] (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/response.js:448:16)
    at internals.Response._prepare.next [as _prepare] (/Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/response.js:387:21)
    at /Users/jaumard/Downloads/testTrails/node_modules/hapi/lib/reply.js:151:22
    at doNTCallback0 (node.js:408:9)
    at process._tickDomainCallback (node.js:378:13)

A better error message can be send like no model default or just 500 server error

jaumard avatar Jan 19 '16 22:01 jaumard

@context trailpack-waterline/api/Services/FootprintService

I guess that this error is due to an undefined reference when a model is recovered from app.orm or app.packs.waterline.orm.collections in FootprintService (line 38 for example).

All FootprintService methods can throws similar error (model not found).

Why there are no check to be sure if a model exists?

enten avatar Feb 07 '16 19:02 enten

@jaumard is this still an issue or can we close?

weyj4 avatar Apr 19 '16 13:04 weyj4

Still an issue but not for hapi I think because it have to be fix/check on trailpack-router or trailpack-footprints or each trailpack-datastore Like @enten say there is no check to see if the model exist. Where we could put this issue ?

jaumard avatar Apr 19 '16 13:04 jaumard

@weyj4 Here is how I fix this for Express and Sequelize On Footprint service (sequelize) : https://github.com/trailsjs/trailpack-sequelize/blob/master/api/services/FootprintService.js#L27 On Footprint controller (express) : https://github.com/trailsjs/trailpack-express/blob/master/api/controllers/FootprintController.js#L25

With this Footprint controller web server doesn't send a 500 whatever the server is (as hapi do actually).

jaumard avatar May 19 '16 08:05 jaumard

Is there a way I can help with this? I have particular interest on fixing the king of errors jaumard refers to on his last comment. Related to this: https://github.com/trailsjs/trailpack-sequelize/pull/23

mautematico avatar Jun 27 '16 17:06 mautematico

How to pass criteria = { column is not null} ?

SrilakshmiGodugunuri7 avatar Mar 23 '20 07:03 SrilakshmiGodugunuri7