GitbookIO / nuts

:chestnut: Releases/downloads server with auto-updater and GitHub as a backend
http://nuts.gitbook.com
Apache License 2.0
1.25k stars 299 forks source link

500 Internal Server Error is being used instead of 400 Bad Request #108

Closed koush closed 2 years ago

koush commented 7 years ago

For example, when no platform is specified: https://github.com/GitbookIO/nuts/blob/master/lib/nuts.js#L150

5XX codes should be used for stuff like... github backend is down, mysql server connection failed, etc. Usually something unexpected and catastrophic. A bad request shouldn't throw this error. 5XX are server errors.

An error in this case should be a 4XX (client error).

I monitor my services for 5XX errors to detect if something is acting up, and caught these (unknown platform, unknown version, etc). I modified Nuts to respond with 400 Bad Request in these cases.