API returns 404 when query produces empty result
matthias-mueller opened this issue · 3 comments
Describe the bug
I am not sure whether this is a bug or intentional: When startDate
and endDate
are declared in such a way that they produce an empty result set, the API throws a 404 at the client.
To Reproduce
Create a test dataset that spans 1979 to 1981, make sure there is a sufficiently large gap between 1980-02-15T13:00 and 1980-02-15T13:01
Then send a query with the following pattern to the API
https://.../attrs/<YYY>?id=<entityId>&startDate=1980-02-15T13:00&endDate=1980-02-15T13:01
Error accessing HTTP resource: (404) - NOT FOUND
Expected behavior
I would expect that the behaviour is similar to SELECT ... WHERE
in SQL: If there there are no matching rows, return OK/200 and an empty result set. Do not throw an Exception or Error at the client.
Plus: HTTP codes 4XX are reserved for client errors. Since the data sits behind an API, there is no other way for the client to know gaps in the data beforehand. If a 404 should make sense here, the client must at least be provided with means to avoid such queries.
p.s.: I hope this is the right place to post this and that I am not knocking at the wrong door.
Hi @matthias-mueller :-)
Thanks for raising this. I agree with you 100%. Ideally Quantum Leap should return an empty result set, not a client error. Unfortunately all our queries work like that at the moment and this is surely something we should fix.
Also keep in mind we never really optimised queries and there are lots of quirks that might surprise or bite you:
@c0c0n3 I would like to contribute for this issue. Please confirm if fix is required.