nwfsc-fram / warehouse

FRAM Data Warehouse - Public
Other
5 stars 1 forks source link

Better API selection error messages #9

Open bjamesvERT opened 5 years ago

bjamesvERT commented 5 years ago
  1. Select https://www.nwfsc.noaa.gov/data/api/v1/source/trawl.catch_fact/selection.json?depth_ftm>30 crashes the API (HTTP 500 error) with no info about why query was invalid. Generic API error message (used for unknown/potentially sensitive errors):
    
    Internal Server Error:
    The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, root@localhost and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

A more helpful HTTP 400 (Bad Request) message which explains what part of the Selection URL was incorrect would enable user self-help. (There's nothing sensitive about a mistyped URL parameter, so just the generic HTTP 500 msg is not necessary.)

2. Select [https://www.nwfsc.noaa.gov/data/api/v1/source/trawl.catch_fact/selection.json?filter=depth_ftm>30&filter=depth_ftm<700](https://www.nwfsc.noaa.gov/data/api/v1/source/trawl.catch_fact/selection.json?filter=depth_ftm%3E30&filter=depth_ftm%3C700) does not crash, but yields a confusing HTTP 400 error that is not much help:

Invalid Parameter The "filters" parameter is invalid. Filters variable "filter|=["depth_ftm" does not exist in data source

bjamesvERT commented 5 years ago

A good 400 message should say:

Invalid parameter
The "depth_ftm@30" parameter is invalid. For help see <a href="https://www.nwfsc.noaa.gov/data/api/v1/help#selection-parameters">available selection parameters</a>.