-
-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Return 404 instead of 406 for json object response with no rows? #1655
Comments
Not sure if changing the status would be a good idea, specially when 406 Not Acceptable is the best semantic fit for a failed Perhaps we could add a field(or use the I've also looked at other REST mechanisms. I found this REST API: https://www.hl7.org/fhir/http.html#patch. It seems it responds 404 for zero rows and (Their implementation also has a |
I think the underlying problem is, that we don't really have a concept of "requesting a single resource". We do have a concept of "requesting a list of resources", with a special case of n=1, where we can use a different output format. At least in terms of what However, when using In terms of Content-Negotiation and
That might be the easiest way out. I think we should do that in any case, even if we were to handle n=0 differently. The number of rows is there, so we can as well send it to the client.
404/412 immediately resonates with me. The whole concept of "requesting a single resource and failing if the query returns multiple resources" has a lot of similarities to the idea of conditional requests.
We do have Just some brainstorming here: Conceptually a list of resources is itself another resource. The URI identifies a resource. By setting the The most natural way to make a distinction in the URL I can think of is by doing Some other ideas:
Nah. Let's add the number of rows to the 406... ;) |
I think the idea of 404/412 could be implemented. After naively thinking about this, I am thinking of defining a new Then for the request @steve-chavez Let me know your thoughts on this. |
@taimoorzaeem I think that the Also, when we fail on a: GET /projects?id=gt.1
Accept: application/vnd.pgrst.object+json The resource collection does exist (hence a So I believe we should stick to the |
A better explanation would be that 412 is meant for conditional requests. |
This may sound insane but maybe if we are working on the premise that the resource is always a collection then maybe a Because the collection still has the properties of being found and empty but after stripping away the Something like this:
This approach would allow clients to use |
Unfortunately this would be a breaking change as some clients are relying on the 4xx status for n = 0.
@PeteDevoy Is it really necessary to have a different status for a n = 0 and n > 1? Another way might be also including |
Currently when making a request with
Accept: application/vnd.pgrst.object+json
, we get the following response, when<> 1
rows are returned:This is status code 406.
With no rows returned, I would expect to get a 404 Not Found. Maybe we can return 404 for no rows, and 406 for multiple rows?
This would help a lot in differentiating those two cases. 404 (no rows) is something that I expect in my case and can handle on the client side. 406 (multiple rows) would mean something went terribly wrong.
The text was updated successfully, but these errors were encountered: