orchestracities / ngsi-timeseries-api

QuantumLeap: a FIWARE Generic Enabler to support the usage of NGSIv2 (and NGSI-LD experimentally) data in time-series databases
https://quantumleap.rtfd.io/
MIT License
37 stars 49 forks source link

API returns 404 when query produces empty result #720

Closed matthias-mueller closed 6 months ago

matthias-mueller commented 1 year ago

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.

c0c0n3 commented 1 year ago

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:

pooja1pathak commented 6 months ago

@c0c0n3 I would like to contribute for this issue. Please confirm if fix is required.

c0c0n3 commented 6 months ago

closed by #752