api icon indicating copy to clipboard operation
api copied to clipboard

afterGet hook error not returned to client

Open jimlambie opened this issue 6 years ago • 0 comments

Expected behaviour

If an afterGet hook errors, the error detail should be returned to the calling application

Actual behaviour

The GET request fails with a 500 error and no detail

Steps to reproduce the problem

Add an afterGet hook to a collection that contains a runtime error, such as a require statement for an uninstalled package. Perform a GET request on the collection.

Failure location

The error is handled and null is returned for processing here: https://github.com/dadi/api/blob/develop/dadi/lib/model/get.js#L86-L90, which causes the 500 to occur here https://github.com/dadi/api/blob/develop/dadi/lib/model/get.js#L97

Package details

API 3.1.2

jimlambie avatar May 07 '18 09:05 jimlambie