I'm looking through an advanced, security related Ruby on Rails tutorial and it's talking about 422 HTTP responses as "the client submitted request was well formed but semantically invalid". I have also seen the latter part rendered as 'semantic errors' or 'semantically erroneous'.
In the example given this was due to Rails checking for an authenticity token, but I significantly feel there is a lot more to the HTTP response.
I would be particularly grateful for a canonical definition from an established community member as to what 'semantically invalid/errors/erroneous' means. What is the general rule that makes a request well formed but not semantically valid?
A 422
(unprocessable entity) status code is given to indicate that the server understood the request, but could not process the logic.
It can be used to indicate things like logic problems (e.g. you asked for an invalid date range to filter on), and validation issues (e.g. you didn't specify a title - which is required). "Semantic error" in this case simply means "logic error".
This distinguishes it from things like lack of permissions (401
or 403
is more appropriate), and also from a generic 400
status which can indicate that the server couldn't understand the request (i.e. it was a malformed request).