fiware-sth-comet
fiware-sth-comet copied to clipboard
Returns 500 when querying historic for non existing entity type
When asking STH API for return historic information for non existing entity type, it returns
{
"statusCode": 500,
"error": "Internal Server Error",
"message": "An internal server error occurred"
}
The request I'm making is as follows (where someEntityType
is a not existing entity type):
curl -X GET \
'sth-host/STH/v1/contextEntities/type/someEntityType/id/d1/attributes/Temperature?aggrMethod=sum&aggrPeriod=hour&lastN=10' \
-H 'Fiware-Service: antel' \
-H 'Fiware-ServicePath: /auto'
I think it should return 404
.
Sorry but I'm not able to reproduce it.
But I've got the following in traces:
iot-sth | time=2018-05-10T09:43:13.301Z | lvl=WARN | corr=0388645f-3cb3-4982-af34-2f9a7a259ba2 | trans=0388645f-3cb3-4982-af34-2f9a7a259ba2 | op=OPER_STH_GET | from=n/a | srv=smartcity | subsrv=/ | comp=STH | msg=Error when getting the raw data collection for retrieval (the collection may not exist)
It seems that in your case collection exits but data are right
Hi @AlvaroVega
I am getting the same result as mentioned by you but as per my understanding 404 should be returned if an entity doesn't exists. Could you please confirm whether my understanding is correct or not?
I'm also unable to reproduce the bug. When I ask for nonexisting type I get a 200 OK with empty results, not a 500 (is 200 a good idea in this case? we are discussing it in a separate issue: https://github.com/telefonicaid/fiware-sth-comet/issues/511)
Thus @gobaldia maybe you have some other kind of problem. Maybe the connection from STH to MongoDB is failing. Did you get in the log a message as the one @AlvaroVega cites?