raster-foundry / granary

Open source repo for AI-supported information feeds

Home Page:https://raster-foundry.github.io/granary

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Improve responses for bad requests

jisantuc opened this issue · comments

If someone tried to use the API to figure out what was wrong with this request, they'd be completely stuck:

$ echo '{"name": "Test", "jobDefinition": "lol", "validation": {"schema": {}}}' | http :8080/api/models
HTTP/1.1 400 Bad Request
Content-Length: 23
Content-Type: text/plain; charset=UTF-8
Date: Mon, 16 Mar 2020 15:29:04 GMT

Invalid value for: body

You get an identical unhelpful response for bad data types, e.g., if you include jobQueue: 3:

$ echo '{"name": "Test", "jobDefinition": "lol", "jobQueue": 3, "validation": {"schema": {}}}' | http :8080/api/models                                                                 481ms
HTTP/1.1 400 Bad Request
Content-Length: 23
Content-Type: text/plain; charset=UTF-8
Date: Mon, 16 Mar 2020 15:28:24 GMT

Invalid value for: body