logoalt Hacker News

Semiapiesyesterday at 9:47 PM3 repliesview on HN

If you're routing like it's 1999, sure, 404.

On the other hand, if it's a CRUD app and you're filtering a list of entities by various field values? Returning that no items matched your selection (or an empty list, if an API) makes more sense than a 404, which would more appropriate for an attempt to pull up a nonexistent entity URI.


Replies

Sander_Marechalyesterday at 10:52 PM

There is no reason you can return that "no items matched your selection" with a 404 HTTP response code instead of a 200.

show 1 reply
stousetyesterday at 10:56 PM

The point was that returning a 404 for unexpected query strings doesn’t just happen to okay per the specs, but that there is significant historical precedent for doing so based on application design that was common in the past.

brightballyesterday at 10:55 PM

Yea, empty response at a valid path. Isn’t 204 the code for it?

Lots of REST libraries that I’ve used treat any 400 response as an error so generating a 404 when for an empty list would just create more headaches.

show 3 replies