sensinov / djane

Context information management for hustle-free data sharing
Eclipse Public License 2.0
15 stars 5 forks source link

Returned error codes and payload not compliant with NGSI-LD standard #32

Closed mainakae closed 5 years ago

mainakae commented 5 years ago

The error codes, as well as payloads, returned by the entity-related queries (at least), are not compliant with the ETSI-CIM NGSI-LD standard.

Errors related to receiving non JSON data, or semantic errors on JSON-LD information, have to answer with 400 error code and a JSON payload containing at least an object indicating the error type (which in those cases should be http://uri.etsi.org/ngsi-ld/errors/InvalidRequest or http://uri.etsi.org/ngsi-ld/errors/BadRequestData).

As an example, in line 114 on routes/entities.js is returning plain text (instead of JSON object) and a wrong error code.

router.post('/entities', auth.checkToken, function (req, res) {
    let verdict = entityValidator.entityValidator(req.body); 
    if (!verdict.correct) {
        res.status(404); 
        res.send('Invalid Request - wrong content: ' + verdict.errorMsg);
    } else { 
        id=req.body.id;       
        entityExistsInDB (id, res, req); 
    }

Best regards, Pedro

gghabri commented 5 years ago

Thanks Pedro for your feedback. This is a duplicated issue (https://github.com/sensinov/djane/issues/18).