-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Respond with 404 status for single resources that do not exist #272
Comments
Definitely a bug. Pr is welcome
…On Thu, Dec 22, 2016, 1:17 AM Jan Buschtöns ***@***.***> wrote:
In accordance with the JSONAPI spec (Fetching Resources > 404 Not Found
<http://jsonapi.org/format/#fetching-resources-responses-404>) Katharsis
must respond with a 404 Not Found status for requests to single resources
that do not exist. It currently responds with 200 Ok.
The response body is also incorrect:
{
"data": null,
"included": []
}
Although the empty included array is unnecessary, it is not illegal per
se, as data is provided. However, "data": null is illegal in this context
and so included is also.
Instead Katharsis should either respond with an empty response body
(discouraged) or a proper errors field. There's an issue over at json-api/json-api#1122
(comment)
<json-api/json-api#1122 (comment)>
elaborating on that.
The perfect response would look similar to this:
HTTP/1.1 404 Not Found
Content-Type: application/vnd.api+json
{
"links": {
"self": "http://example.com/authors/unknown-author"
},
"errors": [
{
"status": "404",
"title": "Not Found",
"detail": "Could not find a resource of type 'author' with id 'unknown-author'."
}
]
}
The only exception to this rule is when requesting a single resource via a
relationship link that is not yet set:
HTTP/1.1 200 OK
Content-Type: application/vnd.api+json
{
"links": {
"self": "http://example.com/articles/1/author"
},
"data": null
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#272>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABaI0Oi7AS5quhEL8lm94UOOWcNoSwU2ks5rKkAzgaJpZM4LTyJ9>
.
|
masterspambot
added a commit
that referenced
this issue
Dec 23, 2016
masterspambot
added a commit
that referenced
this issue
Dec 23, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In accordance with the JSONAPI spec (Fetching Resources > 404 Not Found) Katharsis must respond with a
404 Not Found
status for requests to single resources that do not exist. It currently responds with200 Ok
.The response body is also incorrect:
Although the empty
included
array is unnecessary, it is not illegal per se, asdata
is provided. However,"data": null
is illegal in this context and soincluded
is also.Instead Katharsis should either respond with an empty response body (discouraged) or a proper
errors
field. There's an issue over at json-api/json-api#1122 (comment) elaborating on that.The perfect response would look similar to this:
The only exception to this rule is when requesting a single resource via a relationship link that is not yet set:
The text was updated successfully, but these errors were encountered: