api icon indicating copy to clipboard operation
api copied to clipboard

When collection settings specify a non-existent hook, documents endpoint silently fails

Open ohmoses opened this issue 5 years ago • 0 comments

When a hook is specified in collection settings and there is no code for such a hook provided in the hooks directory, the collection's endpoint returns an empty response body.

This line is a good starting point for a solution.

Steps to replicate

Using the sample API config in the repo ⇒ collection reference has

    "hooks": {
      "afterGet": ["check-reference"]
    }

Accessing /vjoin/testdb/reference?compose=true&fields={}&filter={}&sort={"name":1} (e.g. clicking on "reference" in the header in Publish) gives an empty response body, crashing Publish.

Expected behavior

Ideally, the API should throw an error on start. Less ideally, probably return a meaningful error object in the response.

ohmoses avatar Jun 18 '19 17:06 ohmoses