telefonicaid / fiware-sth-comet

A component of the FIWARE ecosystem in charge of managing historical and aggregated time series context information
https://fiware-sth-comet.rtfd.io
GNU Affero General Public License v3.0
26 stars 27 forks source link

Return 500 when DB is not connected - Include suggestions into prelading PR #588

Closed mapedraza closed 2 years ago

mapedraza commented 2 years ago

This is a PR that intends to merge into #583 a new branch that includes the review's suggestions in order to validate them before including them

mapedraza commented 2 years ago

At this stage, this PR is almost function. Only this failure was returned when executing the tests:

     Uncaught TypeError: Cannot read property 'code' of undefined
      at /Users/mpedraza/Documents/GitHub/fiware-sth-comet/lib/server/handlers/sthRemoveDataHandler.js:69:63
      at /Users/mpedraza/Documents/GitHub/fiware-sth-comet/node_modules/async/dist/async.js:3679:13
      at /Users/mpedraza/Documents/GitHub/fiware-sth-comet/node_modules/async/dist/async.js:952:25
      at iteratorCallback (node_modules/async/dist/async.js:995:17)
      at /Users/mpedraza/Documents/GitHub/fiware-sth-comet/node_modules/async/dist/async.js:847:20
      at /Users/mpedraza/Documents/GitHub/fiware-sth-comet/node_modules/async/dist/async.js:3676:17
      at /Users/mpedraza/Documents/GitHub/fiware-sth-comet/node_modules/async/dist/async.js:339:31
      at processTicksAndRejections (internal/process/task_queues.js:79:11)

There is an error in lib/server/handlers/sthRemoveDataHandler.js quite confusing since the method .code(500) is already used on the file, and this line works properly in the "twin" file: https://github.com/telefonicaid/fiware-sth-comet/blob/1286855bd5ab9b2f77ab1c5c3567f446a2e89239/lib/server/handlers/sthGetDataHandler.js#L68

Leaving the line like the following:

- response = reply(err, { statusCode: 500 }).code(500); 
+ response = reply(err, { statusCode: 500 }); 

would make the tests works, but STH will not return a 500 code when deleting without DB connection (it would return a 500 code only when making a GET request)

fgalan commented 2 years ago

As discussed in skype, we are going to merge this PR into Fix-for-issue-570-prelanding and continue de work in the main PR.