GithubHelp home page GithubHelp logo

Comments (9)

kzangeli avatar kzangeli commented on August 29, 2024

Right now, the broker responds like this:

HTTP/1.1 404 Not Found
Content-Length: 143
Content-Type: application/json
Date: Mon, 06 May 2019 10:05:47 GMT

{
  "type": "http://uri.etsi.org/ngsi-ld/errors/BadRequestData",
  "title": "Entity does not exist",
  "details": "urn:ngsi-ld:doesnotexist"
}

It's not a bad response.

It is also not a bad response to complain about the empty payload.
It's all about the order in which the errors are detected.
If you think that the empty payload should be detected before the non-existing entity, I have no problem with that.
But, I would implement this check in one place only, for all possible requests.
If a payload comes in empty, the broker will return a 400 Bad Request whatever the URI PATH is.

Is that OK?

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

I implemented the check for "{}" (the resulting tree after parsing is a single object of type "Object" and with out children) and this is the new response:

HTTP/1.1 400 Bad Request
Content-Length: 113
Content-Type: application/json
Date: Mon, 06 May 2019 10:26:19 GMT

{
  "type": "http://uri.etsi.org/ngsi-ld/errors/InvalidRequest",
  "title": "Empty Payload",
  "details": "{}"
}

Better like that?

from context.orion-ld.

jmcanterafonseca avatar jmcanterafonseca commented on August 29, 2024

Yes, I think an empty payload is an error that should come before, as it has to do with the content of the request, which is totally incorrect. I also agree that this should be unified for any request.

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

Good. Thanks. PR coming soon to a theater near you :)

from context.orion-ld.

jmcanterafonseca avatar jmcanterafonseca commented on August 29, 2024

@kzangeli what happens if the content of the payload is ""? We need to check that case as well. Also if the content of the payload is null or nothing inside ... (empty byte stream).

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

NULL is already taken care of. Empty I think also.
Will add more tests in the functest of this next PR

from context.orion-ld.

jmcanterafonseca avatar jmcanterafonseca commented on August 29, 2024

and "" because "" is also valid JSON but not semantically correct for our API ... and []

from context.orion-ld.

kzangeli avatar kzangeli commented on August 29, 2024

Fixed in #53

from context.orion-ld.

MohamedSadiq102 avatar MohamedSadiq102 commented on August 29, 2024

#Verified @jason-fox

from context.orion-ld.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.